I want be able to enable and disable navigation buttons when on the first or
last row of a DataGridView object.
I have a populated DataGridView and two buttons - "First Row" and "Previous Row".
If the user clicks "First Row", they are taken to the first row in the DataGridView via:
Expand|Select|Wrap|Line Numbers
- Private Sub btnFirstRecord_Click(...)
- ' Move to first record in job list
- dgvMyRecords.CurrentCell = dgvMyRecords.Rows(0).Cells(0)
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub dgvMyRecords_SelectionChanged(...)
- If dgvMyRecords.CurrentRow.Index = 0 Then
- btnPrevRow.Enabled = False
- Else
- btnPrevRow.Enabled = True
- End if
- End Sub
but not if the first record is selected through the code using CurrentCell.
If I click on the first row, SelectionChanged gets called AFTER the row gets changed.
If I set dgvMyRecords.CurrentCell to dgvMyRecords.Rows(0).Cells(0) (ie. select the first row via code), SelectionChanged gets called, but BEFORE the row gets changed !?!?!?
Can anyone show me how to do this ?
cheers,
Matt.