void _btnCut_Click(object sender, RoutedEventArgs e) { // create undoable cell range action and record the cell values // of the current selection before changing them var action = new CellRangeEditAction(_flex); _flex.Copy(); foreach (var cell in _flex.Selection.Cells) { try { _flex[cell.Row, cell.Column] = null; } catch { } } // record the cell values after the changes and add the // undoable action to the undo stack if (action.SaveNewState()) { _flex.UndoStack.AddAction(action); } }