We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

remove rows from multi-select

What is the best way to remove a range of selected rows from a non bound grid. I tried to use the following but list.Count returns 0 after the first row is removed.

GridRangeInfoList list;
while (true)
{
list = grid.Selections.GetSelectedRows(true, false);
if (list.Count == 0)
break;

GridRangeInfo range = list[0];
int row = range.Top;

grid.Model.Rows.RemoveRange(row,row );
}


2 Replies

JR Joseph Rezuke January 1, 2008 04:01 PM UTC

Let me add to this; this only happens when the selected rows are not contiguous! If the rows are contiguous then it works fine.

>What is the best way to remove a range of selected rows from a non bound grid. I tried to use the following but list.Count returns 0 after the first row is removed.

GridRangeInfoList list;
while (true)
{
list = grid.Selections.GetSelectedRows(true, false);
if (list.Count == 0)
break;

GridRangeInfo range = list[0];
int row = range.Top;

grid.Model.Rows.RemoveRange(row,row );
}





HA haneefm Syncfusion Team January 4, 2008 08:07 PM UTC

Hi Joe,

Please try these code snippet to remove the selected rows in a grid.

GridRangeInfoList list;
list = gridControl1.Selections.GetSelectedRows(true, false);

for(int i = list.Count -1 ;i>=0;i--)
{
GridRangeInfo range = list[i];
this.gridControl1.Model.Rows.RemoveRange(range.Top, range.Bottom);
}

Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon