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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Invert row selection

Thread ID:

Created:

Updated:

Platform:

Replies:

11787 Mar 16,2004 05:38 AM UTC Mar 17,2004 06:00 AM UTC WinForms 3
loading
Tags: GridControl
Raul Rosenthal
Asked On March 16, 2004 05:38 AM UTC

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.

Administrator [Syncfusion]
Replied On 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();
}

Raul Rosenthal
Replied On March 17, 2004 06:00 AM UTC

That worked fine! Thank you!

Raul Rosenthal
Replied On March 17, 2004 06:00 AM UTC

That worked fine! Thank you!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;