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. Image for the cookie policy date

CurrentCellChanged vs. Undo

Hi - we have a GridDataBoundGrid with a CurrentCellChanged handler. This handler performs certain application logic, and overall we are satisfied with the way it works. When the user types into a text box, we see an event fired for each character, and that is fine with us.

However, it seems that if the user presses Control-Z to Undo changes, the CurrentCellChanged handler is not fired for the new value. This causes our application logic to not be invoked, which is a problem.

I read an old post and tried handling the Model.SaveCellInfo handler, but this does not seem to do the trick either, and furthermore only seems to get invoked when after current cell is changed.

I was wondering if there is any way to have the result of Undo call our CurrentCellChanged handler, or some alternative ? Thanks for any assistance !

-Rob


1 Reply

SR Sri Rajan Syncfusion Team May 26, 2008 11:39 AM UTC

Hi Rob,

Thank you for your patience.

If your intention is to call the currentcellchanged event while undo(ie., while pressing Ctrl+Z), you need to handle CurrentCellKeyDown event, then check if Ctrl+Z key is pressed, if so you need to set the IsModified property of CurrentCell to true and set the ControlText property of CurrentCell. Please refer the below code for more details.


void gridDataBoundGrid1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
string s = e.KeyCode.ToString();
bool skipit = false;
if (e.KeyCode == Keys.Control)
skipit = true;

if (!skipit)
{
KeysConverter con = new KeysConverter();
if (e.Control && e.KeyCode == Keys.Z)
{
this.gridDataBoundGrid1.CurrentCell.IsModified = true;
GridCurrentCell cc=this.gridDataBoundGrid1.CurrentCell;
this.gridDataBoundGrid1.CurrentCell.Renderer.ControlText = this.gridDataBoundGrid1.Model[cc.RowIndex,cc.ColIndex].Text;
}
}
}


Here is the minimal sample which solves this issue.
http://websamples.syncfusion.com/samples/grid.windows/F73726/main.htm

Please let me know if this helps.

Best Regards,
Srirajan



Loader.
Live Chat Icon For mobile
Up arrow icon