Private Sub DataGridView1_CellEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
If e.ColumnIndex = 0 Then
'DataGridView1.Rows(e.RowIndex).Cells(1).Selected = True 'Didn't Work
DataGridView1.CurrentCell = DataGridView1.Item(1, e.RowIndex) 'Didn't Work too
End If
End Sub
As you can see in the sample code, I tried two different methods, but neither works. Both throw the error:
Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.
Private cellEnterInUse as boolean=false
Private Sub DataGridView1_CellEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
if not cellEnterInUse Then
cellEnterInUse=True
If e.ColumnIndex = 0 Then
'DataGridView1.Rows(e.RowIndex).Cells(1).Selected = True
DataGridView1.CurrentCell = DataGridView1.Item(1, e.RowIndex)
End If
cellEnterInUse=false
End If
End Sub
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
http://www.dotnetmonster.com/Uwe/Forum.aspx/winform-controls/4634/No-Tab-Stop-DataGridView-Column