Copy Operations

  • 3 minutes to read

The GridControl allows users to copy data displayed within a grid's view to the Clipboard.

Copy at Runtime

End users can copy the GridControl's selected data to the clipboard using the Ctrl+C or Ctrl+Insert shortcuts. This data can then be pasted in another control or application (for example, MS Word, Excel, etc.).

The following image shows a copy operation from the GridControl to the Excel:


The copy operations have the following specifics:

  • Only the visible columns' content is copied.
  • Only the grouping columns' values are copied for group rows. Hidden rows in collapsed group rows are not included.

Copy in Code

End users can copy only selected rows or cells. However, the GridControl provides the following methods that allow you to copy any visible rows or cells:

Method Description
DataControlBase.CopyRowsToClipboard Copies values displayed within the specified rows/cards to the clipboard.
DataControlBase.CopyRangeToClipboard Copies values displayed within the specified row/card range to the clipboard.
DataControlBase.CopySelectedItemsToClipboard Copies values displayed within the selected rows to the clipboard.
DataControlBase.CopyCurrentItemToClipboard Copies values displayed within the focused row to the clipboard.
DataControlBase.CopyToClipboard Copies values displayed within the selected rows or cells to the clipboard.
TableView.CopyCellsToClipboard Copies values displayed within the specified cells to the clipboard.
TableView.CopySelectedCellsToClipboard Copies values displayed within the selected cells to the clipboard.

The following code sample demonstrates how to copy all visible rows to the clipboard:

<dxg:GridControl Name="grid" />  
<Button Click="OnClick">Copy to Clipboard</Button>
void OnClick(object sender, RoutedEventArgs e) {
   grid.CopyRangeToClipboard(0, grid.VisibleRowCount - 1);

Copy with Formatting

Row values are copied to the clipboard as text by default:

  • The newline strings ("\r\n") separate rows in the clipboard.
  • The TAB character ("\t") separates cell values within a row.

The GridControl allows end-users to copy data and its format settings (fonts, cell background, and foreground) to the clipboard. When pasting this data in MS Word, MS Excel, or MS Outlook, the data retains its original formatting:


Set the DataViewBase.ClipboardMode property to Formatted to specify whether copying data and format settings is enabled:

      <dxg:TableView ClipboardMode="Formatted" />

Process Copy Operations

API Description
DataControlBase.ClipboardCopyMode Gets or sets how data is copied to the clipboard.
DataViewBase.ClipboardCopyOptions Specifies formats (Csv, Excel, Html, Rtf, Txt) the data copied from this Grid Control is compatible with.
ColumnBase.CopyValueAsDisplayText Gets or sets whether to copy formatted text or values from the data source.
GridViewBase.ClipboardCopyMaxRowCountInServerMode Gets or sets the maximum number of rows/cards that can be copied to the clipboard in Server Mode.
TableView.ClipboardRowCopying / TreeListView.ClipboardNodeCopying Allows you to apply a format, change the copied data, or skip a data row or header. This event is raised before a data row, group row, column headers, or band headers are copied to the clipboard.
GridControl.CopyingToClipboard Allows you to process copy operations manually. This event is raised before row values are copied to the clipboard by an end user or in code.