Hi,
I am using ultrawingrid 2006 volume
I have situation where I want to know whether grid can undo or not. I have menu which I want to enable or disable on the basis of action.
If I changed any value in the cell then it should return me any value which indicate whether I should enable Undo menu or ReDo.
Is there any property like CanUndo and CanRedo.
Please suggest me.
Try this:
if ((this.ultraGrid1.CurrentState & UltraGridState.CanUndo) == UltraGridState.CanUndo)
Thanks Mike.
I have applied your suggestion but it is always return false. If I have edited the cell and then I call methed canundo and applied your suggested code,
public bool CanUndo() { if ((this.resultsGrid.CurrentState & UltraGridState.CanUndo) == UltraGridState.CanUndo) { return true; } return false; }
Please tell me what am I missing?
Well.. there are two types of Undo at play here.One is related to the Cut, Copy, and Paste functionality that is controlled by the AllowMultiCellOperation property on the grid's Override object. This is related to cutting, copying, and pasting or cells or rows in the grid, and also for Undo and Redo of these operations. That's what the code here is looking at.
When you edit a cell in the grid, the cell displays an Inbox TextBox control over the cell and this TextBox control has it's own Cut, Copy, Paste, Undo, and Redo functionality. So if you are not using AllowMultiCellOperation and you are concerned with an individual cell in edit mode, then you need to use grid.Controls[0] to get the TextBox control and check the CanUndo property on it.
Thanks Mike, For your quick response.
I did but if I do the undo using grid perform action then it undo only character.
Like I have value (ASSDG) in cell when I edit the cell and typed (SSSSSS) when I performed the action it should undo and return the (ASSDG) instead
of that it returns (S). Suggest me. And it always return canUndo true. If I have performed action and undo the text then it should return fals.
We don't have any control over the undo that takes place within a cell while editing. As I explained, this is an Inbox TextBox control.
But if a user wants to cancel the editing of a cell, they can simply press the Esc key. Pressing Esc again will cancel all changes to the current row.
You can simulate this in code (as you can simulate any keyboard behavior of the grid) using the PerformAction method.
I'm not sure I understand. To cancel the cell in edit mode, the user can press Esc. To undo beyond that, you can use the AllowMultiCellOperation property and enable Undo.
I'm not sure if there is any way to get the grid to work exactly like Excel - or what the different is in the behavior between the grid and Excel. It sounds like you might need to code this yourself if you need finer control over the undo functionality.
Hi, After all discussion with client. He is willing that undo should like excel. Like I have typed some characters in one cell and then in next cell and so on. If user press then undo it shoul undo cell one by one. But in grid only that cell and can be undo which is in edit mod. if cell is updated then no way to undo the changes. Please suggest me that method I can use to undo like excel. Further more if you know any article about undo please refer me.