473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.W ebControls.Data Grid
{
override protected bool ProcessCmdKey(r ef System.Windows. Forms.Message msg,
System.Windows. Forms.Keys keyData)
{
if(msg.WParam.T oInt32() == (int) Keys.Enter)
{
SendKeys.Send(" {Tab}");
return true;
}
return base.ProcessCmd Key(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.Dat aGrid". 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 2545
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****@discuss ions.microsoft. com> wrote in message
news:A1******** *************** ***********@mic rosoft.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.W ebControls.Data Grid
{
override protected bool ProcessCmdKey(r ef System.Windows. Forms.Message
msg,
System.Windows. Forms.Keys keyData)
{
if(msg.WParam.T oInt32() == (int) Keys.Enter)
{
SendKeys.Send(" {Tab}");
return true;
}
return base.ProcessCmd Key(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.Dat aGrid". 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...(ins tead 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(e vent,id)
{
var key=event.keyCo de;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getEle mentById(id).cl ick();
}
}
--
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****@discuss ions.microsoft. com> wrote in message
news:A1******** *************** ***********@mic rosoft.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.W ebControls.Data Grid
{
override protected bool ProcessCmdKey(r ef System.Windows. Forms.Message
msg,
System.Windows. Forms.Keys keyData)
{
if(msg.WParam.T oInt32() == (int) Keys.Enter)
{
SendKeys.Send(" {Tab}");
return true;
}
return base.ProcessCmd Key(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.Dat aGrid". 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****@discuss ions.microsoft. com> wrote in message
news:1F******** *************** ***********@mic rosoft.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(ins tead 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(e vent,id)
{
var key=event.keyCo de;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getEle mentById(id).cl ick();
}
}
--
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****@discuss ions.microsoft. com> wrote in message
news:A1******** *************** ***********@mic rosoft.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.W ebControls.Data Grid
> {
> override protected bool ProcessCmdKey(r ef
> System.Windows. Forms.Message
> msg,
> System.Windows. Forms.Keys keyData)
> {
> if(msg.WParam.T oInt32() == (int) Keys.Enter)
> {
> SendKeys.Send(" {Tab}");
> return true;
> }
> return base.ProcessCmd Key(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.Dat aGrid". 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.RegisterOn SubmitStatement ("submit","retu rn DisallowEnterKe y(event);");

here is my javascript function.

function DisallowEnterKe y(event)
{
alert("key kode in DisallowEnterKe y(): "+event.keyCode );
if(event.keyCod e==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****@discuss ions.microsoft. com> wrote in message
news:1F******** *************** ***********@mic rosoft.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(ins tead 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(e vent,id)
{
var key=event.keyCo de;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getEle mentById(id).cl ick();
}
}
--
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****@discuss ions.microsoft. com> wrote in message
news:A1******** *************** ***********@mic rosoft.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.W ebControls.Data Grid
> {
> override protected bool ProcessCmdKey(r ef
> System.Windows. Forms.Message
> msg,
> System.Windows. Forms.Keys keyData)
> {
> if(msg.WParam.T oInt32() == (int) Keys.Enter)
> {
> SendKeys.Send(" {Tab}");
> return true;
> }
> return base.ProcessCmd Key(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.Dat aGrid". 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
1889
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: - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q745q - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q758q - http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q837q Basicly it works like this: Every time a cell has...
1
384
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 myDataGrid.Select(rowNum); MessageBox.Show is coming up, but this takes no effect on Select or Focus. Anybody knows why?
0
1565
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 struggled to get the code right. Could you pleas eprovide some sample code or some pointers how to achieve what I want Thanks a lot in a advance -- Treat everyone like you want to be treated !!! Stardv
1
1776
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 do it.... Can someone tell me how to do it Here is an example of how I am doing this: if ((msg.Msg == WM_KEYDOWN) && (keyCode == Keys.Down))
0
1445
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 primera captura ... pero para controlar dentro de una datagrid, por ejemplo, si han pulsado ctrl+inicio , cmo puedo hacerlo? Muchas gracias y un saludo
1
8318
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: http://www.dotnet247.com/247reference/msgs/52/262224.aspx In this procedure, MS suggested to use SendKeys.Send(" "), but I am finding that this locks my machine, and SendWait() causes an infinite loop of messages (stack overflow). How to convert a SHIFT-SPACE message to be just a SPACE? Below is...
2
1282
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 hidden. I have checked my backcolor and forecolor, and don't see anything wrong there. I know this is probably a simple q. Here is the code. Can anybody help? arevans using System; using System.Collections.Generic; using...
5
6162
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 method, then the user can press keys A, D, E, F, T, and C to peform a function. What i want is that if a user presses A, or a, or SHIFT A or CNTRL A that it executes the same code, BUT NOT IF ALT A is pressed. The same
2
6531
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
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.