I am performing greid undo/redo with UltraGridAction.Undo/Redo. It is working fine.
1. Is there a way to know when undo stack == 0 so I can disable the button>
2. same question for redo stack
3. Is there a way to grab the cell that was undone / redone so I can change it's background color
4. I set the background color of a changed cell with UpdateCellEvent and Cell.Appearance.BackColor. How do I "remove" the attribute so it reverts back to it's default background color (to be done in undo)
Peter
Hi Peter,
howudodat said: 1. Is there a way to know when undo stack == 0 so I can disable the button> 2. same question for redo stack
Check out this thread.
howudodat said:3. Is there a way to grab the cell that was undone / redone so I can change it's background color
I think you can use events like Before/AfterMultiCellOperation for this.
You could call cell.ResetAppearance(). Of course, you will need to keep track of which cells have appearances applied to them so you know which ones to clear.
#1 Solved...thanks
#2. There is no AfterMultiCellOperation. There is a Before and changing the color there works, except that the undo changes the value of the cell which then calls the UpdateCellEvent and changes the color back to "changed".
PeterPS. the corect function is cell.Appearance.Reset(); foreach (UltraGridCell cell in e.Cells) cell.Appearance.Reset()
howudodat said: #2. There is no AfterMultiCellOperation. There is a Before and changing the color there works, except that the undo changes the value of the cell which then calls the UpdateCellEvent and changes the color back to "changed". Is there a way to know if the change came because of an undo event? Where is the AfterMultiCellOperation event?
Sorry, I guess I just assumed there was an After event to go along with the Before. But sometimes there isn't one.
I'm not sure what you are referring to when you say UpdateCellEvent. I assume you mean either BeforeCellUpdate, AfterCellUpdate, or CellChanged.
In general, if you are applying colors to cells or rows, it's a good idea to base it on some persistent state value of the row and then apply all of the appearances inside the InitializeRow event. So I probably would not use any other event to color a cell. Instead, you could add an unbound column to the grid and use it to store state information, such as when the cell has changed. Then inside InitializeRow you can color the row based on that information.