FlexGrid provides flexibility to perform various clipboard operations such as cut, copy, and paste on the editable grid data. To enable automatic handling of common clipboard keys, you need to set the AutoClipboard property to true. The property handles following clipboard operations and their corresponding keys:
Copy |
CTRL+C, Ctrl+INS |
Cut | CTRL+X, SHIFT+DEL |
Paste | CTRL+V, SHIFT+INS |
Delete | DEL |
The above mentioned clipboard operations do not have any affect on the styles and images and only work on grid headers and data. You can choose which part of the selected content to copy out of row header, column header and data by using the ClipboardCopyMode property. However, the copy operation does not support merged cells within the grid. When a datamap or multicolumn combobox exists in the copied range, only the display value is copied. Also, note that hidden cells are also copied when copying a cell range. To exclude hidden cells from copying, see Exclude Hidden Cells.
The code below demonstrates how to enable clipboard operations in the WinForms FlexGrid.
FlexGrid provides Cut, Copy, and Paste methods in the C1FlexGrid class which can be used to implement clipboard operations on the entire grid or a selected part of the grid. This enables you to quickly copy or cut the required data and paste the copied content onto the current selection.
The following example demonstrates how to perform copy and paste operations on button click.
Similarly, you can implement the above mentioned clipboard operations on various types of selected ranges within the grid. These selected ranges could be contiguous, like row range, column range, or non-contiguous, like multi-range. For non-contiguous selection ranges like multi-range, the selected range must lie within a common row or column range.
In FlexGrid, by default, hidden cells are also copied when copying a cell range through keyboard operations enabled using the AutoClipboard property. However, you can exclude the hidden rows and columns by using the code below.
Following code shows how you can exclude the hidden cells from clipboard operations performed on the WinForms Tree Grid.