[]
All the Clipboard operations, Cut,Copy, and Paste commands are supported by C1FlexSheet controls. You can easily cut, copy, or paste data in FlexSheet.
The following code performs the cut operation in C1FlexSheet control:
vbnet
' create undoable cell range action and record the cell values
' of the current selection before changing them
Dim action = New CellRangeEditAction(flex)
flex.Copy()
For Each cell In flex.Selection.Cells
Try
flex(cell.Row, cell.Column) = Nothing
Catch
End Try
Next
' record the cell values after the changes and add the
' undoable action to the undo stack
If action.SaveNewState() Then
flex.UndoStack.AddAction(action)
End If
csharp
// 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);
}
The above code refers a class named CellRangeEditAction which includes the implementation of recording the values of all the cells within the current selection of the control.
Data from cell(s) can easily be copied in C1FlexSheet control using Copy method. The following code uses Copy method to copy the data from the selected cells:
vbnet
flex.Copy()
csharp
flex.Copy();
Data from cell(s) can easily be pasted in C1FlexSheet control using Paste method. The following code uses Paste method to paste the copied data:
vbnet
flex.Paste()
csharp
flex.Paste();