I have a three column DataGridView and I want a user enter Tab in the last column to go to the next row but to column 1 instead of column 0. The following code gets an error System.StackOverflowException
I see code out there on how to change CurrentCell from buttons but the events (ChangeCurrentCell, CellLeave) seem to tolerate changing the current cell.
Private Sub dgvEngine_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles dgvEngine.CellLeave
If mbLoadEng = True Then Exit Sub
If e.ColumnIndex = 2 Then
dgvEngine.CurrentCell = dgvEngine(1, e.RowIndex + 1)
End If
End Sub
How do I change the current cell from a DataGridView event?
I'm not limited to this approach - I'm just trying to skip Column 0 as the users tabs through the cells.
Found a better approach to my specific case - use the Row HeaderCell...
dgvEngine.Rows(iRow).HeaderCell.Value = col.ColumnName.Substring(1)
later
dgvEngine.AutoResizeRowHeadersWidth(
DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)
col.ColumnName is from a DataRow. What I am doing essentially is a transposed grid with DataRow column names as row headers.