jeudi 29 décembre 2016

How can I check each line in a datagridview to see if a checkbox is checked and then delete those which are checked

I've been looking around on here and other sites to try and find a solution to my problem. As the title says I want to loop and check each line in the datagrid to see if the checkbox is check if so then that row is deleted. Also this program is connected to a Access DB. This is the code which I have so far:

 For Each oRow As DataGridViewRow In dvgSupport.Rows
        If oRow.Cells("completeCheck").Value = True Then
            TblSupportSystemBindingSource.RemoveCurrent()
            Try
                TblSupportSystemBindingSource.EndEdit()
                TblSupportSystemTableAdapter.Update(EntireDBDataSet.tblSupportSystem)
                MsgBox("Data has been saved", vbOKOnly, "Success")
            Catch ex As Exception
                MsgBox("An error has occured", vbOKOnly, "Error")
            End Try
        Else
            MsgBox("n")
        End If
    Next

I believe that is only checking to see if all the checkboxes within the designated column are checked then it will remove the current however if only one is checkbox is checked then nothing will happen. Any help would be much appreciated.

TIA




Aucun commentaire:

Enregistrer un commentaire