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

CurrentCellChanged vs. Undo

Thread ID:

Created:

Updated:

Platform:

Replies:

73726 May 15,2008 05:43 PM UTC May 26,2008 11:39 AM UTC Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 15, 2008 05:43 PM UTC

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


Sri Rajan [Syncfusion]
Replied On 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



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

;