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

Deselecting a row that I selected

Thread ID:

Created:

Updated:

Platform:

Replies:

73222 Apr 24,2008 08:50 PM UTC May 9,2008 11:15 AM UTC Windows Forms 1
loading
Tags: GridControl
Paul
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?

thanks



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:

[C#]

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

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.gridControl1.Selections.Ranges.Clear();
this.gridControl1.RefreshRange(range);
this.lastSelectedRow = -1;
this.ignoreCurrentCellChange = true;

}
else
{
this.lastSelectedRow = row;
this.ignoreCurrentCellChange = true;
}

}


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

http://websamples.syncfusion.com//samples/Grid.Windows/F73222/main.htm

Please try this and let me know if this helps.

Thanks,
Melba




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

;