Home Forums WinForms controls Xceed Grid for WinForms Very simple questions Reply To: Very simple questions

User (Old forums)
Member
Post count: 23064

That is because you are removing rows from the beginning to the end. This will cause problems because the next row won’t be the next row upon next iteration of the loop because you are removing a row, and all other rows will be reordered. The way to stop this is going from the last to the first.

You need to do something like:

for(int i = gridContro1.SelectedRows.Count; i > 0; i–)
{
if(gridControl1.SelectedRows(i) is DataRow)
{
gridControl1.SelectedRows.Remove(i);
}
}

Imported from legacy forums. Posted by hellswraith (had 4621 views)