CurrentCellMoving cancel causes CurrentCellMoving event fired again

Salute,

I am using GridControl. I just noticed while processing CurrentCellMoving event if I set GridCurrentCellMovingEventArgs.Cancel to true, the event is triggered again for the same current cell.

Should it be considered as an issue, or it works as designed?

Thank you,
Alex Feldman.

P.S. I attached slightly modified sample.

combotest.zip

2 Replies

AF Alex Feldman June 15, 2007 05:38 PM UTC

I forget to mention that I am using version 5.102.0.51 against .NET 2.0 in VS 2005


SA Saravanan A Syncfusion Team June 16, 2007 01:47 AM UTC

Hi Alex,

We could see this issue here. When we try to navigate between the cells it will fire the CurrentCellMoving event and if we set the e.Cancel to true, it will stop the moving and the CurrentCellMoving event will not raise again.
But if we try to navigate using mouse it will raise the CurrentCellMoving event to set the clicked cell as the CurrentCell. In this case if set the e.Cancel it will stop moving the CurrentCell, but it will still try to scroll the grid to make the clicked cell fully visible, while doing this it is raising the CurrentCellMoving event again with different e.Option argument (GridSetCurrentCellOptions.ScrollInView).
Now, you can avoid the execution of your code twice by adding some conditional logic using this argument.

Here is the modified code snippet of your CurrentCellMoving event handler.

void m_Grid_CurrentCellMoving(object sender, GridCurrentCellMovingEventArgs e)
{
GridCurrentCell cc = m_Grid.CurrentCell;
if (!(cc.MoveFromRowIndex == cc.MoveToRowIndex && cc.MoveFromColIndex == cc.MoveToColIndex))
{
if (e.Options == GridSetCurrentCellOptions.ScrollInView && !cc.MoveToDone)
{
e.Cancel = m_Closing;
return;
}
}
if ((cc.RowIndex == m_ForcedRowIndex) && (cc.ColIndex == m_ForcedColIndex) && m_Grid.CurrentCell.HasCurrentCell)
{
OutputLine("Cell Moving!");
//
// write your code here to do the required task
//
e.Cancel = m_Closing;
}
}


Best Regards,
Saravanan

Loader.
Up arrow icon