Question
I am using C#, Windows application.
Is it possible to cancel OnGridCellSelectChanged events?
I have a popup form that says do you wish to change yes/no, is there a way to cancel this event?
CODE:
private void gantt1_OnGridCellSelectChanged(Cell cell, CellSelectChangedEventArgs cellSelectChanged)
{
bool temp;
submitcancel SCForm = new submitcancel();
SCForm.ShowDialog();
temp = SCForm.getStatus();
if(temp) {
//continue}
else {
//ignore event
}
}
Answer
The event fires when changes occur in the Selected property of the Cell. So in princip you will get one call when the first cell is unselected and another call when the new cell is selected.
To null out the action here you can simply toggle the Select value back; cell.Selected = ! cellSelectChanged.NowSelected //( possible recursive problem?)
But I think that you want to make sure that the Grid.GridStructure.FocusedCell is not changed, so something like this:
private void grid1_OnBeforeFocusedCellChange(PlexityHide.GTP.Grid grid, BeforeFocusedCellChangeEventArgs beforeFocusChange)
{
// This event allows you do control when cells are focused (when user moves with click or arrow keys)
if (beforeFocusChange.OldFocusedCell!=null && beforeFocusChange.NewFocusedCell!=null)
{
if (beforeFocusChange.OldFocusedCell.Column.Index==2 && beforeFocusChange.NewFocusedCell.Column.Index==1)
{
// For some reason I do want the user to be able to move backwards from cell2 to cell1 horizontally
beforeFocusChange.NewFocusedCell=beforeFocusChange.OldFocusedCell;
}
}
}