DataGridCell KeyDownEvent

G

Guest

Hi
I've used the following code to intercept a KeyEvent into a DataGrid.

******************************************
Private Sub DataGrid1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGrid1.KeyDown
' Check if F2 Key is pressed.
If e.KeyCode = Keys.F2 Then
' Key pressed, Show MsgBox
MsgBox("F2 Key pressed!", MsgBoxStyle.Exclamation, "Ok, event Intercepted")
End If
End Sub
******************************************

When the cursor is into a cell of my DataGrid, the MsgBox doesn't appear. If I select, by example, the caption text part of the DataGrid control and then I press F2 Key, the event is intercepted and MsgBox appear!

But I don't want it. I want intercept the event when the cursor is located into a cell of my DataGrid!
What should I do to intercept that event?

Thanks in advance
 
K

Ken Tucker [MVP]

Hi,

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q836q

Ken
--------------
Nicola Baldi said:
Hi!
I've used the following code to intercept a KeyEvent into a DataGrid.

******************************************
Private Sub DataGrid1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles DataGrid1.KeyDown
' Check if F2 Key is pressed.
If e.KeyCode = Keys.F2 Then
' Key pressed, Show MsgBox
MsgBox("F2 Key pressed!", MsgBoxStyle.Exclamation, "Ok, event Intercepted")
End If
End Sub
******************************************

When the cursor is into a cell of my DataGrid, the MsgBox doesn't appear.
If I select, by example, the caption text part of the DataGrid control and
then I press F2 Key, the event is intercepted and MsgBox appear!
 
G

Guest

Hi, i have the same problem, i saw the code but i don't know how to raise an event handler to trap de F2 key control and then show a new form. Please help me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top