I am trying to find the current row index of the selected row in a winforms Datagridview. I have put this code in every event I can think of and of the ones that fire when the row position changes none return the current row index. the best I can get is the index of the row I am coming from. I have tried it in many events. What I am trying to do is identify what row the user is on so if they click a button of the main form I can show a data entry form to edit the current row.
dgvShift_Printers_CellClick, BindingSource_CurrentChanged,BindingSource_PositionChanged
If dgvShift_Printers.RowCount > 0 Then
Dim ri As Integer = dgvShift_Printers.CurrentRow.Index
Dim ci As Integer = dgvShift_Printers.CurrentCell.RowIndex
MsgBox("I am here = " & ri)
End If