Good Day, i am develop a program for datagridview check box clear check box below is my code
can someone help me take a look
datagriview check box
Dim CheckboxColumn As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()
Dim chk As CheckBox = New CheckBox()
checkBoxColumn.HeaderText = ""
checkBoxColumn.Width = 30
checkBoxColumn.Name = "checkBoxColumn"
DataGridView1.Columns.Insert(0, checkBoxColumn)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Clear.Click
For Each row As DataGridViewRow In DataGridView1.Rows
Dim chk As DataGridViewCheckBoxCell = CType(row.Cells(1), DataGridViewCheckBoxCell)
If chk.Selected = True Then
chk.Selected = False
Else
chk.Selected = True
End If
Next
DataGridView1.EndEdit()
End Sub
End Class
i get error message on Button1_Click
Unable to cast object of type 'System.Windows.Forms.DataGridViewTextBoxCell' to type 'System.Windows.Forms.DataGridViewCheckBoxCell'.