Xceed Grid for WinForms v4.3 Documentation
How to copy and paste rows to and from a grid
Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Events > How to copy and paste rows to and from a grid

The grid does not provide built-in functionality to copy and paste or drag and drop rows to and from another application such as Excel, however it is quite easy for you to implement (a sample is provided below). In order to copy rows from a grid you need to:

  1. Handle the keyboard shortcuts (Ctrl-C, Ctrl-V, etc.). 

  2. You need to create a DataObject that will contain a compatible DataFormat. For example plain text, CSV or HTML data formats are all supported by Excel. 

  3. Once you have your DataObject, you can place it in the ClipBoard using the ClipBoard class's SetDataObject method.

You can then paste your result into Excel or any other application that supports the data formats you provided. In order to paste rows into a grid you need to:

  1. Retrieve the DataObject in the ClipBoard using the DataObject's GetData method. You can decide which data format you want to use. The easiest one to use with the grid is plain text (DataFormats.PlainText). 

  2. Once you have your DataObject, you will need to parse it and retrieve the data. 

  3. Once you have retrieved your data, add the new rows to the grid.

Demonstration

Sample applications that demonstrate how to copy and paste as well as drag and drop rows to and from Excel are available for download: 

C# sample application 

VB.NET sample application