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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Deselecting a row that I selected

Thread ID:





73222 Apr 24,2008 08:50 PM UTC May 9,2008 11:15 AM UTC WinForms 1
Tags: GridControl
Asked On April 24, 2008 08:50 PM UTC

First, may I make a suggestion that you make this text box wider since people post code and it would make it easier to read:

Here is the real question. I am using the gridcontrol and I look at the CellClick event, and inside it I select the entire row when the user selects a cell:

grid_.Selections.SelectRange(GridRangeInfo.Rows(e.RowIndex, e.RowIndex), true);

The next time the click the same row, I want to deselect it. But it seems that when I get here, the row is already deselected somewhere and I cannot tell if I need to select it or not. Any suggestions to get the select/deselect working correctly?


Melba Winshia [Syncfusion]
Replied On May 9, 2008 11:15 AM UTC

Hi Paul,

Thank you for your suggestion.

We regret for the delayed response.

You can deselect the selected row by clicking any cell in the selected row by using CurrentCellMoved event. Please use below code snippet to achieve this behavior:


private void gridControl1_CurrentCellMoved(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellMovedEventArgs e)
if(this.ignoreCurrentCellChange == true)
this.ignoreCurrentCellChange = false;

int row = this.gridControl1.CurrentCell.RowIndex;
GridRangeInfo range = GridRangeInfo.Row(row);
if(this.lastSelectedRow != -1 && this.lastSelectedRow == row && this.gridControl1.Selections.Ranges.Contains(range))
this.lastSelectedRow = -1;
this.ignoreCurrentCellChange = true;

this.lastSelectedRow = row;
this.ignoreCurrentCellChange = true;


Please refer the sample in the below link which illustrates the above:


Please try this and let me know if this helps.



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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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