Enterキーを押してTABのような別のセルに移動する私の作業コードは次のとおりです。
Private Sub dvFromAlloc_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dvFromAlloc.KeyDown
If e.KeyCode = Keys.Enter Then
Dim colm As Integer = dvFromAlloc.ColumnCount - 1
Dim row As Integer = dvFromAlloc.RowCount - 1
Dim currCell As DataGridViewCell = dvFromAlloc.CurrentCell
If currCell.ColumnIndex = colm Then
If currCell.RowIndex < row Then
'gets the next row and the first selected index
dvFromAlloc.CurrentCell = dvFromAlloc.Item(0, currCell.RowIndex + 1)
End If
Else
'move in next col in the current row
dvFromAlloc.CurrentCell = dvFromAlloc.Item(currCell.ColumnIndex + 1, currCell.RowIndex)
End If
e.Handled = True
End If
End Sub
Private Sub dvFromAlloc_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dvFromAlloc.CellEndEdit
isEdited = True
iColumnindex = e.ColumnIndex
irowindex = e.RowIndex
End Sub
Private Sub dvFromAlloc_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvFromAlloc.SelectionChanged
If isEdited Then
isEdited = False
dvFromAlloc.CurrentCell = dvFromAlloc.Item(iColumnindex + 1, irowindex)
End If
End Sub
ここでの主な問題は、最後の行にいるときは、セルを編集した後、別のセルに移動する前に Enter キーを 2 回押す必要があることですが、他の行にいる場合は、編集後に Enter キーを 1 回だけ押します。次のセルに移動します。
ご協力ありがとうございました