Example E831
Visible to All Users

WinForms Data Grid - How to paste data from the Clipboard

The Grid Control supports row copy and paste operations out-of-the-box. Set the GridView.OptionsClipboard.PasteMode property to Update or Append to enable the Paste from Clipboard functionality.

Users can copy/paste rows to/from the Clipboard using the CTRL+C and CTRL+V (or Shift+Insert) shortcuts, respectively.

Use the GridView.CopyToClipboard and GridView.PasteFromClipboard methods to copy/paste rows in code.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

Main.cs(vb)
C#
using System; using System.Collections.Generic; using System.Linq; using DevExpress.XtraEditors; namespace PasteData { public partial class Main : XtraForm { public Main() { InitializeComponent(); gridControl1.DataSource = DataHelper.GetData(10); gridView1.OptionsSelection.MultiSelect = true; gridView1.OptionsClipboard.PasteMode = DevExpress.Export.PasteMode.Append; } private void OnButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e) { if (e.Button.Properties.Caption == "Copy") { gridView1.CopyToClipboard(); } if (e.Button.Properties.Caption == "Paste") { gridView1.PasteFromClipboard(); } } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.