Key down an datagridview

  • Thread starter Thread starter chris81
  • Start date Start date
chris81 said:
hello
can i make to captur the key down event on cell's datagridview??

thx

I just recently had a need to do this myself. First, you can get the
editing control for that cell by handling the EditingControlShowing
event of the DataGridView. Then you can subscribe to the KeyDown event
of the editing control.
 
Le 01/11/2006, (e-mail address removed) a supposé :
I just recently had a need to do this myself. First, you can get the
editing control for that cell by handling the EditingControlShowing
event of the DataGridView. Then you can subscribe to the KeyDown event
of the editing control.

have you got an example ?

thx
 
Dans son message précédent, chris81 a écrit :
Le 01/11/2006, (e-mail address removed) a supposé :

have you got an example ?

thx

yes i add

Private Sub dataGridView1_EditingControlShowing(ByVal sender As
Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles
dgCompositionFormule.EditingControlShowing

e.CellStyle.BackColor = Color.Aquamarine

End Sub

but how can i captur key ??

thx
 
chris81 said:
Le 01/11/2006, (e-mail address removed) a supposé :

have you got an example ?

thx

In your EditingControlShowing event, do something like this:

dgv.EditingControl.KeyDown += CellKeyDown;

Then define your event handler (CellKeyDown) for the KeyDown event.
 
James Daughtry a formulé la demande :
In your EditingControlShowing event, do something like this:

dgv.EditingControl.KeyDown += CellKeyDown;

Then define your event handler (CellKeyDown) for the KeyDown event.

one complete example please because i don't understand.... :(

thx
 
chris81 said:
James Daughtry a formulé la demande :

one complete example please because i don't understand.... :(

thx

That was a complete example. Presumably you know how to write a KeyDown
even handler, so the only unfamiliar part is the single line I gave
you:

Private Sub dataGridView1_EditingControlShowing(ByVal sender As
Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles
dgCompositionFormule.EditingControlShowing
dgCompositionFormule.EditingControl.KeyDown += CellKeyDown
End Sub

Private Sub CellKeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
' Whatever you want to do when the key is down here
End Sub
 
James Daughtry avait écrit le 03/11/2006 :
That was a complete example. Presumably you know how to write a KeyDown
even handler, so the only unfamiliar part is the single line I gave
you:

Private Sub dataGridView1_EditingControlShowing(ByVal sender As
Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles
dgCompositionFormule.EditingControlShowing
dgCompositionFormule.EditingControl.KeyDown += CellKeyDown
End Sub

Private Sub CellKeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
' Whatever you want to do when the key is down here
End Sub

thanks
 
Back
Top