getting the affected cell ranges in spread undo events

Posted by: ericjwo on 8 September 2017, 3:17 pm EST

  • Posted 8 September 2017, 3:17 pm EST

    My last topic disappeared before I could get a satisfactory answer, so I am reposting my question with more info. I have a function that is run every time the spread Change event is called, which uses the changed cell information. Since Undo/Redo does not trigger the Change event (nor does Cut/Paste), I tried to use the UndoManager's ActionComplete event to call my function. Unfortunately, the ActionComplete event contains an UndoAction (usually the CellEditUndoAction) which has the affected cell ranges as protected fields. Meaning, I cannot call my function with the affect cell ranges when an Undo action is performed. I am not trying to create a custom UndoAction. I am simply trying to handle the UndoAction that is triggered normally and call my function with the affected cell range.
  • Replied 8 September 2017, 3:17 pm EST

    Ok, I will try to illustrate my problem. I have the following function:

    void CellChanged(int row, int column)
    {
    ...
    }

    I want it called every time the value of a cell is changed. I make such a call in my spread Change event handler. For example:

    spread.Change += SpreadChange;

    ...

    voidSpreadChange(object sender, ChangeEventArgs e)
    {
    CellChanged(e.Row, e.Column);
    }

    I need CellChanged called whenever a cell's value changes, which means I need it called when data is pasted into the cell. The spread Change event is not fired off when data is pasted into the cell. As far as I can tell, the only event that is fired off is the ActionComplete event for the Spread's Undo Manager. I can hook into that like so:

    spread.UndoManager.ActionComplete += UndoManager_ActionComplete;

    ...

    void UndoManager_ActionComplete(object sender, FarPoint.Win.Spread.UndoRedo.UndoRedoEventArgs e)
    {
    CellChanged(e.Row, e.Column); // does not work
    }

    In the UndoManager's ActionComplete event handler, I want to call my CellChanged function with the affected cell's row and column, but the UndoRedoEventArgs Action property is an UndoAction, typically a CellEditUndoAction, which does not expose the row and column index of the cell that is being changed.

    So my question is, how can I make sure that my CellChanged function is called with the correct parameters when data is Pasted into the spread?
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    Could you please provide a small working sample depciting the behavior you are getting.
    We need to debug your code at our end and provide you with some solution.
    Hence, please provide us with a small working sample along with exact steps.

    We will look into this further.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:17 pm EST

    One small clarification. In my example I want the CellChanged event to be called with the correct parameters when an Undo action is performed, because the Undo event does not contain the information I need. I mistakenly said the Paste event, which I have handled because it does contain the information I need.
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    You need to handle different events for calling the same function on every action performed.

    For that you can create a function and can call it everytime with different events.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:17 pm EST

    I am trying to hook into the multiple events so that each one call my function with the affected cellrange. My problem is that the only even that I can catch for an Uno/Redo is the UndoManager's events, which only provide UndoActions, typically a CellEditUndoAction, which do not expose the affected cellranges. I can see from the documentation that the CellEditUndoAction does have the affected cellrange information, but that the fields are private. Without accecss to the affected cell ranges, how can I call my own function with the cellrange information that it needs?

    In other words, how can I handle Undo/Redo actions if I don't know which cellranges have been affected?
  • Replied 8 September 2017, 3:17 pm EST

    Hello,

    We agree that UndoManager event doesn't provide you with cellRange which is affected. However, you can try creating a new control by inheriting Spread control and can override the events as per your need.

    Thanks,
    Reeva
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels