[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Collapse]Data Editing and Validation
     Add and Remove Rows
    [Expand]Modify Cell Values
    [Expand]Input Validation
    [Collapse]Clipboard Management
      Copy Operations
      Paste Operations
   [Expand]Filtering and Searching
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Copy Operations

The GridControl allows copying data displayed within a grid's view to the Clipboard (see System.Windows.Clipboard). This topic consists of the following sections:

Expanded Copying 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.

Expanded Copying 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:

Expanded Copying 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:

Expanded Copying Customization

You can use the following properties to customize copy operations:

Property 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.
GridViewBase.ClipboardCopyMaxRowCountInServerMode Gets or sets the maximum number of rows/cards that can be copied to the clipboard in Server Mode.

The following code sample demonstrates how to copy data without column headers. This data is compatible with the Csv and Excel formats:

Expanded Processing Copy Operations

The GridControl provides the GridControl.CopyingToClipboard event that 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.

The following code sample demonstrates how to process data that is copied to the clipboard:

The GridControl.CopyingToClipboard event is raised only if the GridControl does not have an active cell editor. Use the DataViewBase.ActiveEditor property to detect whether the GridControl contains an active cell editor.


The GridControl.CopyingToClipboard event is not raised if the DataControlBase.ClipboardCopyMode property is set to ClipboardCopyMode.None.

Is this topic helpful?​​​​​​​