I have a Windows Form that contains a Datagridview control. This control has 2 columns, one is a DataGridViewCheckBoxCell (which is checked by default) and the other is a TextBox cell. If DGV contains multiple rows, I can check/uncheck the CheckBox for all rows except the first row (0 index). I don't understand why this happens for the first row only. Below is the code I have for this DGV.
Code:Private Sub dgvSN_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvSN.CellMouseUp 'Debug.Print("dgvSN_CellMouseUp") Try EH.ErrorMessage = String.Empty If e.RowIndex > -1 And e.ColumnIndex = 0 Then Dim cboSelected As DataGridViewCheckBoxCell = CType(dgvSN.Rows(e.RowIndex).Cells(0), DataGridViewCheckBoxCell) If CBool(cboSelected.Value) = True Then cboSelected.Value = False 'Even when this line is executed, the checkbox WON'T uncheck for the very first row Else cboSelected.Value = True End If End If Catch ex As Exception EH.ErrorMessage = "frmCertificates/dgvSN_CellMouseUp() - " & ex.Message & "~E" End Try EH.ProcessMessages(Me, sbr, EH.ErrorMessage) End Sub




Reply With Quote