Link to home
Start Free TrialLog in
Avatar of Richard Kreidl
Richard KreidlFlag for United States of America

asked on

Delete row in DGV(DataGridView) using checkboxes

Basically, in my first column I have checkboxes that are unbound.

I would either like to be able to remove the row by checking the checkboxes or clicking a button after a checkbox(s) are checked.

I have some code below that I 've been working with which I found on the web, but it's not working..

thanks

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each row As DataGridViewRow In DataGridView1.Rows
            If (row.Cells.Item(0).Value = CheckState.Checked) Then
                DataGridView1.Rows.RemoveAt(0)                                                      'This way doesn't work
                DataGridView1.Rows.Remove(DataGridView1.SelectedRows(0))         'This way doesn't work either  
            End If
        Next
 End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of vwalla
vwalla

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Kreidl

ASKER

thanks