[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
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [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
     Examples
   [Expand]Grouping
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [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
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Paste Operations

You and your end-users can paste data from the Clipboard in the GridControl. This topic consists of the following sections:

Expanded Pasting At Runtime

Starting from version 17.2, end-users can paste plain and formatted data in the GridControl using the Ctrl+V or Shift+Insert shortcuts:

Paste operations have the following specifics:

  • If a target column cannot accept any value in a pasted row, this row is skipped.
  • Pasting graphics data is not supported.
  • Read-only and non-editable columns are skipped during pasting in the Update (see PasteMode) paste mode.
  • Adding new rows is disabled if the data source does not allow adding new rows.

Appending Data

You can use paste operations to add new rows to the GridControl. In this case, the pasted data is added as new rows to the data source, and the GridControl is updated. The data source has to support adding new rows to allow pasting.

In the following image, the paste operation adds data from Excel to the GridControl:

Set the TableView.PasteMode (or TreeListView.PasteMode) property to Append to allow pasting:

Updating Data

You can use pasting to update existing GridControl's cells. In the following image, the paste operation updates GridControl's data by data from the Excel:

Set the TableView.PasteMode (or TreeListView.PasteMode) property to Update to allow pasting:

Expanded Pasting In Code

You can use the TableView.OnPaste (or TreeListView.OnPaste) method to paste data from the clipboard in the GridControl. The following code sample demonstrates how to update the required row with the clipboard's data:

Expanded Processing Paste Operations

The GridControl provides the following events that allow you to process paste operations manually. Handle these events to override the default pasting behavior and perform custom actions:

Event Description
TableView.ClipboardRowCellValuePasting (or TreeListView.ClipboardRowCellValuePasting) Raises for each pasted cell before updating the GridControl. Use this event to modify pasted data or to cancel pasting.
TableView.ClipboardRowPasting (or TreeListView.ClipboardRowPasting) Raises for each pasted row before updating the GridControl. Use this event to modify pasted data or to cancel pasting.
DataControlBase.PastingFromClipboard Raises after an end-user pressed Ctrl+V or Shift+Ins. Use this event to implement custom data pasting.

The following code sample demonstrates how to use the TableView.ClipboardRowCellValuePasting event to modify pasted values. This sample removes underscore characters from pasted strings and applies "camel case" formatting:

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