RE: Capture ENTER key in vb.net datagrid
From: Foef (Foef_at_discussions.microsoft.com)
Date: 01/25/05
- Next message: Larry Serflaten: "Re: best way to do this"
- Previous message: Miguel A. Martín Benavides: "Help me, with MSComm!!"
- In reply to: Melson: "Capture ENTER key in vb.net datagrid"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 Jan 2005 09:13:03 -0800
Steve,
To capture keypress event in a datagrid you should use the ProcessCmdKey
function.
for example:
Public Class MyDataGrid
Inherits DataGrid
Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, keyData As System.Windows.Forms.Keys) As
Boolean
If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
SendKeys.Send("{Tab}")
Return True
End If
OR
Const WM_KEYDOWN As Integer = &H100
Const WM_SYSKEYDOWN As Integer = &H104
If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
Select Case (keyData)
Case (Keys.Control Or Keys.M)
Case (Keys.Alt Or Keys.Z)
Case Keys.Delete
End Select
End If
Return MyBase.ProcessCmdKey(msg, keyData)
End Function 'ProcessCmdKey
End Class 'MyDataGrid
Greetinx,
Foef
"Melson" wrote:
> hi
>
> can anyone help me how can i capture ENTER keystroke when the cell in
> datagrid is in editing mode.
>
> I'm now creating a data entry form with primary key in header and details in
> datagrid. So when user key in the details in datagrid, I would like user to
> choose product code by pressing ENTER key in the datagrid and a Product Code
> dialog will appear for him to choose.
>
> Pls help. Thanks very much.
>
> Regards
> Steve
>
>
>
- Next message: Larry Serflaten: "Re: best way to do this"
- Previous message: Miguel A. Martín Benavides: "Help me, with MSComm!!"
- In reply to: Melson: "Capture ENTER key in vb.net datagrid"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|