Hi
I'm in the process of migrating from a different grid to your GridControl. For the other grid control I had to write my own command classes to handle applying fonts/colours etc. to a selected range, and to provide my own undo/redo functionality.
I would like to use the built-in undo/redo but am not sure as to whether I need to create my own classes again, inheriting from GridModelCommand. I've looked at the UndoRedoSample and I think that works fine for me, but I need to be able to set the description for each type of command.
For example, if I set the font colour for a range of cells, I would like to display "Font Colour" in the undo list, rather than "Change Cells R5C2..." But how can I determine what was changed from the GridChangeCellsCommand?
hope that makes sense!
thanks
Richard
RB
Richard Bysouth
June 21, 2007 03:26 AM UTC
Actually, I've just answered this myself!
I just need to use a transaction for each command. This makes things so easy!
For example:
grid.CommandStack.BeginTrans("Font Color")
Dim cellInfo As New GridStyleInfo
cellInfo.TextColor = dlg.Color
'Apply the settings to the current selection
grid.ChangeCells(selectedRange, cellInfo)
grid.CommandStack.CommitTrans()