This is a migrated thread and some comments may be shown as answers.

Multiple rows delete

3 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mampus
Top achievements
Rank 1
mampus asked on 25 Dec 2010, 04:19 PM
Hi there, 
I just got an problem with raddatagridview, i want to delete some rows...how i could do that..??
fyi i'm use mysql for the database....
thanks for your help...

3 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 25 Dec 2010, 09:44 PM
Hello,

Can you please provide some more details on exactly what you are trying to achieve here?

There are a lot of different ways you can handle the row deletion,
First and foremost the most easiest way is to handle the UserDeleting/UserDeletedRow event and update db there.
Another option would be to handle the RowsChanging event and check for the Remove action, like so:
void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e)
{
    if (e.Action == NotifyCollectionChangedAction.Remove)
    {
        //update db
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
mampus
Top achievements
Rank 1
answered on 26 Dec 2010, 01:21 AM
hi there...
well, in this case, i have one button called "delete", then the user just select the rows that they want to delete then it's done..
how i can achieve that...??(btw, i'm using vb.net...)

thanks anyway for your help....
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 26 Dec 2010, 08:00 PM
Hello again,

Please take a look at the following sample:
Private Sub button_Click(sender As Object, e As EventArgs)
    Dim selectedRows = radGridView1.SelectedRows.ToArray()
    For i As Integer = selectedRows.Length - 1 To 0 Step -1
        Dim row = selectedRows(i)
            ' do something else maybe here
        radGridView1.Rows.Remove(row)
    Next
End Sub

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
Tags
GridView
Asked by
mampus
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
mampus
Top achievements
Rank 1
Share this question
or