Default Penekanan key enter pada Datagrid adalah pindah baris di kolom yg sama sekarang kita mau membikin pindah pada baris yg sama pada kolom yg berbeda :
Public Class ClassMyGrid
Inherits System.Windows.Forms.DataGridView
Public IdxRow As SByte
Public IdxCol As SByte
Sub lanjut()
IdxRow = Me.CurrentCell.RowIndex – 1
IdxCol = Me.CurrentCell.ColumnIndex
End Sub
Private Sub dg_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.CellEnter
lanjut()
End Sub
Private Sub Datagridview1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.Enter And IdxCol < Me.ColumnCount – 1 Then
Me.CurrentCell = Me(IdxCol + 1, IdxRow)
Else
Me.CurrentCell = Me(0, IdxRow + 1)
End If
End Sub
End Class