You can use Ctrl + Z to undo an action in the control. You can then use Ctrl + Y to redo the action you canceled.
You can undo the following types of actions:
- Editing text
- Autofit when double-clicking
- Resizing headers
- Dragging columns or rows with the mouse
- Expanding or collapsing groups with the group button
- Editing the sheet tab name by double-clicking on the tab strip
- Using Ctrl + V to paste
- Using the DoCommand to create a row or column group
The following actions do not respond to Ctrl + Z:
- Sorting or filtering with the drop-down button
- Selecting a range
- Navigating to a specific cell
- Scrolling
- Dragging a split box to create new viewports
- Resizing the tab strip resize box
- Double-clicking the new tab option on the tab strip
You can prevent or allow the undo action in code with the CanUserUndo property.
Using Code
The following example creates an action that can be undone.
CS |
Copy Code |
gcSpreadSheet1.CanUserUndo = true;
private void button1_Click(object sender, RoutedEventArgs e) { GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupExtent group = new GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupExtent(3, 5); GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupUndoAction action = new GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupUndoAction(this.gcSpreadSheet1.ActiveSheet, group); this.gcSpreadSheet1.DoCommand(action); gcSpreadSheet1.Invalidate(); } |
VB.NET |
Copy Code |
GcSpreadSheet1.CanUserUndo = True
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click Dim group As New GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupExtent(3, 5) Dim action As New GrapeCity.Windows.SpreadSheet.UI.UndoRedo.RowGroupUndoAction(GcSpreadSheet1.ActiveSheet, group) GcSpreadSheet1.DoCommand(action) GcSpreadSheet1.Invalidate() End Sub |
See Also