Actually what I am trying to do is to give the user chance to undo changes by
calling BindingSource.CancelEdit()
And making Save button which is updating changes to the database By calling
the update Tableadaptor method so I have to call Remove or RemoveAt Or what
do u think?
To delete multiple rows in a datagridview I am using
try
{
for (int i = Main2DGrdView.SelectedCells.Count - 1; i >= 0;
i--)
{
mAIN1MAIN2RelationBindingSource.RemoveAt
(Main2DGrdView.SelectedCells[i].RowIndex);
}
}
catch (Exception ex)
{
MessageBox.Show("Deleted failed" + "\n" + ex.Message);
}
It raise the exception ArgumentOutOfRangeException
So how to force the program to only delete row and jump to next selected row
and deleted too
Thank you in advance
mmsjed
"Cor Ligthert[MVP]" wrote:
As I see that you use a datatable: first the question, do you want to use
remove? Remove means that it is removed from the collection, not giving the
dataadapter the change to remove it from the database?
Cor
"MMSJED" <MM****@discussions.microsoft.comschreef in bericht
news:3B**********************************@microsof t.com...
How to let user delete multi rows from the BindingSource while the
SelectionMode Property set to RowHeaderSelect
I have in my program datagridview bound it to sql table
Throw Bindingsource
To fill it:
MyTableTableAdaptor.fill(MyDataset.Mytable);
MyTableBindingSource.datasource = MyDataset;
MyTableBindingSource.datamember = MyDataset;
Datagridview.datasource = MyTableBindingSource;
To delete from it:
MyTableBindingSource. Removecurrent();
This only removes one item at the time so how I can let the user delete
multi selected rows
Thank you in advance