Invert row selection

I cannot find an easy way to invert the current (row) selection in a grid. What I am trying to do is the following: I want to let the user select some rows, then press a button and have the selected rows unselected, while the previously unselected rows should become selected. Can you help, please? Thank you.

3 Replies

AD Administrator Syncfusion Team March 16, 2004 08:56 AM UTC

Here is one solution that worked for me.
private void button1_Click(object sender, System.EventArgs e)
{
	GridRangeInfoList rangeList = this.gridControl1.Selections.GetSelectedRows(true, false);
	this.gridControl1.BeginUpdate();
	for(int row = 1; row <= this.gridControl1.RowCount; ++row)
	{
		GridRangeInfo range = GridRangeInfo.Row(row);
		if(rangeList.AnyRangeContains(range))
		{
			this.gridControl1.Selections.Remove(range);
		}
		else
		{
			this.gridControl1.Selections.Add(range);
		}
	}
	this.gridControl1.EndUpdate();
	this.gridControl1.Refresh();
}


RR Raul Rosenthal March 17, 2004 06:00 AM UTC

That worked fine! Thank you!


RR Raul Rosenthal March 17, 2004 06:00 AM UTC

That worked fine! Thank you!

Loader.
Up arrow icon