delete a rows using checkbox in datagridview
I has one problem in i know how to delete single row with the help of header selction of a gatagridview. i want your help in which how can i delete a multiple rows using checkbox..... But i preserved a row sequence... how i can delete a row 开发者_开发技巧using checkbox in datagridview with a click of button......give me any reference for it ... site...or code.....
My Cell for the check box is called: ToDelete
Code in form for button:
Private Sub Button_Delete_Checked_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Delete_Checked.Click
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells("ToDelete").Value Then
MessageBox.Show(row.Cells("SomeText").Value & " will be deleted.")
End If
Next
End Sub
Here's the grid to give you an idea of the fields and data I manually entered.
Result of clicking the button.You'll need to insert code to do the deletion in place of the messagebox code. You can get the row index with: row.Index.
精彩评论