windowsforms-114874-common-features-clipboard.md
The clipboard is a set of operations that allow users to transfer data between applications.
The Data Grid and Tree List controls allow users to copy/paste rows to/from the clipboard. To copy rows to the clipboard, select the rows and press Ctrl+C. To paste data, focus the target row and press Ctrl+V or Shift+Insert.
Tip
Run the following demos and copy the selected rows to the clipboard:
Run Demo: Data Grid Run Demo: TreeList
Click Open Solution in the Ribbon UI to get the source code.
Note
The Vertical Grid and PDF Viewer controls support clipboard operations in plain-text mode only — format settings (fonts, colors, etc.) are not copied/pasted.
In code, use the following methods to copy the selected rows to the clipboard:
The GridView.OptionsClipboard property provides access to the following options:
The TreeList.OptionsClipboard property provides access to the following options:
The Data Grid and Tree List controls support the RTF, HTML, and BIFF8 (Microsoft Excel) formats. These formats allow you to copy data along with format settings — fonts and cell colors. When data is pasted to Microsoft Word, Excel, or Outlook, the formatting is preserved.
To copy formatted data, set the ClipboardMode property to Formatted.
gridView1.OptionsClipboard.ClipboardMode = DevExpress.Export.ClipboardMode.Formatted;
treeList1.OptionsClipboard.ClipboardMode = DevExpress.Export.ClipboardMode.Formatted;
gridView1.OptionsClipboard.ClipboardMode = DevExpress.Export.ClipboardMode.Formatted
treeList1.OptionsClipboard.ClipboardMode = DevExpress.Export.ClipboardMode.Formatted
Note
In the GridControl, only the GridView, BandedGridView, and AdvBandedGridView support copying formatted data to the clipboard.
The controls always use all supported formats. To improve performance, you can use the following options to disable the corresponding format:
The controls show a progress bar when copying or pasting large portions of formatted data.
Use the ShowProgress property to specify whether the progress bar is shown. Note that this property is only in effect in formatted mode.
You can access copied data and apply a format to a cell, change the copied data, or skip a data row or header. The image below illustrates a default copy-and-paste operation.
The following figure illustrates the same operation with a custom format applied to the Sales column header:
The following events fire before a data row, group row, column headers, or band headers are copied to the clipboard, and allows you to update data or skip the row:
The following properties return objects that provide data for the clipboard:
These objects provide data for the clipboard in different formats (plain text, rich text, plain Unicode text, CSV, BIFF8, HTML). Use the provider’s methods to get the data selected in the control that will be passed to the clipboard if a user presses Ctrl+C. For example, the TreeListClipboardDataProvider.GetTextData method returns data for the clipboard in plain-text format.
Data pasting is initially disabled in Data Grid and Tree List controls. Use the PasteMode setting to allow paste operations.
Note
The following controls and components do not support paste operations:
Users can paste plain-text and formatted data to the Data Grid and Tree List controls. To paste data, press Ctrl+V or Shift+Insert. In code, use the following methods:
The following formats are supported:
Set the ClipboardOptions.PasteMode property to Append or Update to allow paste operations.
Append — the control adds new rows at the end of the list.
Update — the control updates cells below and to the right of the focused cell. Cells above and to the left of the focused column are not updated.
The PasteAsChildNodes option specifies whether to paste data as child or sibling nodes.
The following events fire before a data row is pasted to the control, and allows you to update data or skip the row:
Paste operations have the following limitations: