FlexSheet for WPF | ComponentOne
Working with C1FlexSheet / Cell Operations / Clipboard Operations
In This Topic
    Clipboard Operations
    In This Topic

    All the Clipboard operations, Cut,Copy, and Paste commands are supported by C1FlexSheet controls. You can easily cut, copy, or paste data in FlexSheet.

    Cut Operation

    The following code performs the cut operation in C1FlexSheet control:

    ' 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
    
    // 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.

    Copy operation

    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:

    flex.Copy()
    
    flex.Copy();
    

    Paste operation

    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:

    flex.Paste()
    
    flex.Paste();