Deselecting a row that I selected
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
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
SIGN IN To post a reply.
1 Reply
MW
Melba Winshia
Syncfusion Team
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:
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
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
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
PA Paul
- Apr 24, 2008 08:50 PM UTC
- May 9, 2008 11:15 AM UTC