Delete multiple selected rows on datatable

johnoxy

New member
Joined
May 24, 2007
Messages
1
Programming Experience
Beginner
Hi
I have a windows form that has a datagrid with a datatable bound to it. What i am trying to work out is how to allow a user to select multiple rows and hit a button that will collect the rows selected so i can then update several database tables. I am having trouble working out a way of identifying the rows selected. Any ideas would be appreciated.

Cheers
 
hello >>>

VB.NET:
Private Sub DeleteMultiRow()
        Try
            'If there is remaining row.
            If Me.EmployeesDataGridView.Rows.Count >= 0 Then
                'Loop through all of selected Rows.Count
                For Each SelectedRow As DataGridViewRow In    
                     EmployeesDataGridView.SelectedRows
                    'Remove all of selected Rows.
                    EmployeesDataGridView.Rows.Remove(SelectedRow)
                Next

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
Hi
I have a windows form that has a datagrid with a datatable bound to it. What i am trying to work out is how to allow a user to select multiple rows and hit a button that will collect the rows selected so i can then update several database tables. I am having trouble working out a way of identifying the rows selected. Any ideas would be appreciated.

Cheers


DataGridView already does this.. Highlight the rows, press the delete button, call .Update() on the tableadapter..
 
Back
Top