H
Henry J.
Can somebody tell me how to delete multiple rows in a datagridview
selected by the user?
I tried the following two methods to no avail. I have a myDataGridView
that is bound to
myDataTable's myDataView. The column "Name" is the primary key.
I want to delete the rows selected by the user:
foreach (DataGridViewRow drv in myDataGridView.SelectedRows)
{
// this is not working, no error but does nothing
foreach (DataRowView drview in myDataView)
{
if (drview["Name"].Equals(drv.Cells["Name"]))
{
drview.Delete();
}
}
// nor is this working, same effect
foreach (DataRow dr in myDataTable.Rows)
{
if (dr["Name"].Equals(drv.Cells["Name"]))
{
dr.Delete();
}
}
}
I've searched through all the info I could, still could find anything.
Any help is
much appreciated!
Henry Jiang
selected by the user?
I tried the following two methods to no avail. I have a myDataGridView
that is bound to
myDataTable's myDataView. The column "Name" is the primary key.
I want to delete the rows selected by the user:
foreach (DataGridViewRow drv in myDataGridView.SelectedRows)
{
// this is not working, no error but does nothing
foreach (DataRowView drview in myDataView)
{
if (drview["Name"].Equals(drv.Cells["Name"]))
{
drview.Delete();
}
}
// nor is this working, same effect
foreach (DataRow dr in myDataTable.Rows)
{
if (dr["Name"].Equals(drv.Cells["Name"]))
{
dr.Delete();
}
}
}
I've searched through all the info I could, still could find anything.
Any help is
much appreciated!
Henry Jiang