Hello,
I've 2 questions:
1-How to make the first column in a datagridview visible but has no focus when moving to a new row in a datagrid? Therefore,I want to give always the focus to the second column when moving to a new row.
2-I am using visual studio 2008 and I wantthe enter key move to the next cell in a datagridview instead of the tab key.I searched over and over and I've found a solution that overrides the 2 functions
ProcessDialogKey and OnKeyDown.Is there any other recent solution in visual basic 2008?
The code that I've found is:
Class
Inherits DataGridView
Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
If keyData = Keys.Enter Then
Dim col As Integer = Me.CurrentCell.ColumnIndex
Dim row As Integer = Me.CurrentCell.RowIndex
If Not (row = Me.NewRowIndex) Then
If col = (Me.Columns.Count - 1) Then
End If
Me.CurrentCell = Me(col + 1, row)
End If
Return True
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
Protected Overloads Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
If e.KeyData = Keys.Enter Then
Dim col As Integer = Me.CurrentCell.ColumnIndex
Dim row As Integer = Me.CurrentCell.RowIndex
If Not (row = Me.NewRowIndex) Then
If col = (Me.Columns.Count - 1) Then
End If
Me.CurrentCell = Me(col + 1, row)
End If
True
End If
MyBase.OnKeyDown(e)
End Sub
Class
Sam85