I am fairly new to VB.Net so please excuse the elementary question. I am using a DataGridView to display data that the user will select full rows of the data. I have added a checkbox column (first column) for the user to visually see the rows that were selected. I am trying to set that if the checkbox is selected then the row is selected and if the row is selected then the checkbox is selected. Consequently I am trying to get the opposite to be true for unselecting.
Private Sub DataGridView1_CbxRowSelect(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim CellChecked As DataGridViewCheckBoxCell = DataGridView1.Rows(e.RowIndex).Cells(0)
Dim SelectedRow As DataGridViewRow = DataGridView1.Rows(e.RowIndex)
If CellChecked.Value = True Then
SelectedRow.Selected = True
End If
If CellChecked.Value = False Then
SelectedRow.Selected = False
End If
If SelectedRow.SelectedCell = True Then
Checked.Value= True
End If
End Sub
Any help would be appreciated, Thank you!
Aucun commentaire:
Enregistrer un commentaire