hi Marc,
use this code
------------------------------------------------------------------------------
Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
If DataGridView1.CurrentCell.ColumnIndex = DataGridView1.ColumnCount - 1 Then
If DataGridView1.CurrentCell.RowIndex < DataGridView1.RowCount - 1 Then
DataGridView1.CurrentCell = DataGridView1.Item(0, DataGridView1.CurrentCell.RowIndex + 1)
End If
Else
DataGridView1.CurrentCell = DataGridView1.Item(DataGridView1.CurrentCell.ColumnIndex + 1, DataGridView1.CurrentCell.RowIndex)
End If
End If
e.Handled = True
End Sub
Dim LastEditedCell As DataGridViewCell
Sub getLastCell()
Try
Dim r, c As Short
r = LastEditedCell.RowIndex
c = LastEditedCell.ColumnIndex
LastEditedCell = Nothing
DataGridView1.CurrentCell = Me.DataGridView1.Rows(r).Cells(c + 1)
Catch Ex As Exception
MsgBox(Ex.Message)
End Try
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
LastEditedCell = DataGridView1.CurrentCell
End Sub
Private Sub DataGridView1_CellEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
If Not LastEditedCell Is Nothing Then
If (DataGridView1.CurrentCell.RowIndex = LastEditedCell.RowIndex + 1) And (DataGridView1.CurrentCell.ColumnIndex = LastEditedCell.ColumnIndex) Then
System.Windows.Forms.Form.CheckForIllegalCrossThreadCalls = False
Dim subThread As New Threading.Thread(AddressOf getLastCell)
subThread.Start()
End If
End If
End Sub
------------------------------------------------------------------------------
Regards,
James fredric.
[quoted text, click to view] >Hi,
Can someone help me for next problem
How to for using ENTER key to move to the right cell instead of the TAB key
Many thanks in advance
Marc.
___