VB Gurus,
I have a problem with in capturing the Enter Key for DatagridView Control.
i.e. I want to move to the next column when I press the Enter Key, instead of taking me to the next row.
the code below captures key even when editing the cell but the Enter Key does not fire ..
'***********************************************************************************************************************
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler DataGridView1.EditingControlShowing, AddressOf DataGridView1_EditingControlShowing
Me.DataGridView1.RowCount = 1
End Sub
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
Dim txtbox As TextBox = CType(e.Control, TextBox)
If Not (txtbox Is Nothing) Then
AddHandler txtbox.KeyPress, AddressOf txtBox_KeyPress
End If
End Sub
Private Sub txtBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
MsgBox(e.KeyChar.ToString)
End Sub
End Class
'***********************************************************************************************************************
This problem was there in VB6 and its solved by placing a textbox control on top of a cell and moving the textbox using its KeyPress events.
I don't want to follow this approach.
Anyone with ideas of solving then problem.?
--
Regards,
Kamiru Mwangi,
Skype: samuel.kamiru