Re: deleting selected rows in a DataGrid

From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 09/16/04


Date: Thu, 16 Sep 2004 19:14:22 +0300

Hi,

You can create an ArrayList in which the indexes of the selected rows will
be accumulated. Then, unselect all rows and use the prepared list of indexes
to delete the rows from the data view.

-- 
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"Mojtaba Faridzad" <mfaridzad@hotmail.com> wrote in message
news:unkoaR$mEHA.3876@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> with SetDataBinding( ) a DataGrid shows a DataView. user can select some
> rows in the grid by holding cotrol key. when user clicks on Delete button,
I
> should delete all selected rows. I am trying to delete these lines from
the
> dataview like this:
>
> for (int i=0; i < dataView.Count; i++)
>     if (dataGrid.IsSelected(i))
>        dataView.Delete(i);
>
> but after deleting the first line, all other selected rows, become
> unselected and I cannot delete the rest of selected rows. how can I ask
> DataGrid not to reset the status of rows?
>
> thanks
>
>