473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

issue with overriding ProcessCmdKey() in DataGrid

Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a drop
down box. The second datagrid is populated by viewing details from a row of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key in
any editable textbox calls my inital search function that populates my first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other then
i have 3 different overrides that give me the same error (the ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).

Nov 19 '05 #1
4 2521
in the web version of the grid, the keystrokes happen on the client unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
Hello. I have wrapped the DataGrid control with my own class
(SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a
drop
down box. The second datagrid is populated by viewing details from a row
of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key
in
any editable textbox calls my inital search function that populates my
first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message
msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other
then
i have 3 different overrides that give me the same error (the
ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).

Nov 19 '05 #2
thanks bruce. duh! ok that makes sense. about the javascript: i actually
have already done that. here's the function...(instead of tabbing this one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function is
called my initial search function (btnSite_Click()) is called as well. I can
place break points in both and within one request both breakpoints are hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
Hello. I have wrapped the DataGrid control with my own class
(SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a
drop
down box. The second datagrid is populated by viewing details from a row
of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key
in
any editable textbox calls my inital search function that populates my
first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message
msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other
then
i have 3 different overrides that give me the same error (the
ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).


Nov 19 '05 #3
the enter key fires a postback, unless client code captures it and cancels
the event.

-- bruce (sqlwork.com)
"jibran" <ji****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(instead of tabbing this
one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function
is
called my initial search function (btnSite_Click()) is called as well. I
can
place break points in both and within one request both breakpoints are
hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client
unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
> Hello. I have wrapped the DataGrid control with my own class
> (SmartDataGrid)
> adding some necessary functionality. My current webform has 2
> SmartDataGrids. The first is populated by selected information from a
> drop
> down box. The second datagrid is populated by viewing details from a
> row
> of
> the first datagrid.
>
> When editing individual rows (in either datagrid), clicking the enter
> key
> in
> any editable textbox calls my inital search function that populates my
> first
> datagrid. I want the enter key to tab to the next location. yes,
> simple!
>
> All the documentation I've come across tells me to override the
> ProcessCmdKey(). So I did just that. Here is my code...
>
>
> public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
> {
> override protected bool ProcessCmdKey(ref
> System.Windows.Forms.Message
> msg,
> System.Windows.Forms.Keys keyData)
> {
> if(msg.WParam.ToInt32() == (int) Keys.Enter)
> {
> SendKeys.Send("{Tab}");
> return true;
> }
> return base.ProcessCmdKey(ref msg, keyData);
> }
> }
>
> The error i'm getting is "no suitable method found to override". I
> have
> found this article (HOW TO: Trap Keystrokes:
> http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one
> HUGE
> difference is that their example overrides the
> "System.Windows.Forms.DataGrid". I'm overriding the
> "System.Web.UI.WebControls.DataGrid". If i change from one to the
> other
> then
> i have 3 different overrides that give me the same error (the
> ProcessCmdKey
> acutally compiles in this case).
>
> I've run out of ideaRs..........
> thanks for your help in advance...
>
> --
> jibran :^).
>


Nov 19 '05 #4
Hi Bruce. I'm undertanding what i need to do. I have added a startup script
to my form with this line:

Page.RegisterOnSubmitStatement("submit","return DisallowEnterKey(event);");

here is my javascript function.

function DisallowEnterKey(event)
{
alert("key kode in DisallowEnterKey(): "+event.keyCode);
if(event.keyCode==13)
return false;
}

however, everytime the function is called the keyCode is always 0. it is
never 13 when i hit the enter key. Any ideas?
thanks
jibran

--
jibran :^).

"Bruce Barker" wrote:
the enter key fires a postback, unless client code captures it and cancels
the event.

-- bruce (sqlwork.com)
"jibran" <ji****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(instead of tabbing this
one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function
is
called my initial search function (btnSite_Click()) is called as well. I
can
place break points in both and within one request both breakpoints are
hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client
unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
> Hello. I have wrapped the DataGrid control with my own class
> (SmartDataGrid)
> adding some necessary functionality. My current webform has 2
> SmartDataGrids. The first is populated by selected information from a
> drop
> down box. The second datagrid is populated by viewing details from a
> row
> of
> the first datagrid.
>
> When editing individual rows (in either datagrid), clicking the enter
> key
> in
> any editable textbox calls my inital search function that populates my
> first
> datagrid. I want the enter key to tab to the next location. yes,
> simple!
>
> All the documentation I've come across tells me to override the
> ProcessCmdKey(). So I did just that. Here is my code...
>
>
> public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
> {
> override protected bool ProcessCmdKey(ref
> System.Windows.Forms.Message
> msg,
> System.Windows.Forms.Keys keyData)
> {
> if(msg.WParam.ToInt32() == (int) Keys.Enter)
> {
> SendKeys.Send("{Tab}");
> return true;
> }
> return base.ProcessCmdKey(ref msg, keyData);
> }
> }
>
> The error i'm getting is "no suitable method found to override". I
> have
> found this article (HOW TO: Trap Keystrokes:
> http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one
> HUGE
> difference is that their example overrides the
> "System.Windows.Forms.DataGrid". I'm overriding the
> "System.Web.UI.WebControls.DataGrid". If i change from one to the
> other
> then
> i have 3 different overrides that give me the same error (the
> ProcessCmdKey
> acutally compiles in this case).
>
> I've run out of ideaRs..........
> thanks for your help in advance...
>
> --
> jibran :^).
>


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DraguVaso | last post by:
Hi, I 'wrote' my own DataGrid, using the normal DataGrid, and overriding some of the DataGridTextBoxColumn-methods (mostly the Paint-method). I based most of my changes on the Windows Form FAQ:...
1
by: Susanne Christe | last post by:
Hi Folks, I'm trying to override protected ProcessCmdKey function in writing my a custom MyDataGrid. I get the Keys I want, but it takes no effect to MyDataGrid, if I try for example execute...
0
by: stardv | last post by:
I am trying to override ProcessCmdKey to either bind the data on “Enter” key pressed or return the value of the current cell when enter is pressed on it, whatever would be easier. I have...
1
by: Diogo Alves - Software Developer | last post by:
I'm tring to override the combination all the combination like this one Ctrl + Shift + . I just can't catch it... I have already done this for ctrl + or Shift + but for both at same timeI can't...
0
by: Pablo Melero | last post by:
Buenas tardes, necesitara me ayudseis a conseguir controlar desde la funcin ProcesscmdKey la pulsacin de dos teclas a la vez ... no lo consigo de ninguna manera, parece que solo permite la...
1
by: John Richardson | last post by:
I'm trying to override the SHIFT-SPACE "negative feature" in the Winforms datagrid, to only be a space. The following link describes this:...
2
by: arevans | last post by:
I built a custom control 'ChooseBox' that inherits from ComboBox. When I select an item from a choosebox control, the selected item does not show up; I mean, the background is blue, but the text is...
5
by: Peted | last post by:
Hello, i am lookinf for the best way to trap any alphanumeric keypress in all multi key combminations and execute some code For example , i have a form visible using the form.showdialog...
2
by: Trooper | last post by:
Hi! I need help with calling ProcessCmdKey. I'm little bit confused how to use this method from my app. How to call it, from where? Can somebody explain to me? Thnx. This is the source:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.