We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the Copy and Paste option of the Grid by using ContextMenu and SfRibbion?

In SfDataGrid, you can enable copy and paste option by setting value to SfDataGird.GridCopyoption and SfDataGrid.GridPasteoption. You can use the copy and paste options through keyboard shortcuts. And you can also copy, paste data programmatically in SfDataGrid using the following methods.

  1. Cut - GridCopyPaste.CutData()
  2. Copy - GridCopyPaste.Copy()
  3. Paste – GridCopyPaste.Paste()

The following section explains how to integrate programmatic copy paste with Ribbon and ContextMenu

Integrating SfDataGrid copy paste with Ribbon

Here, Ribbon is designed with Button for performing copy paste operations and SfDataGrid is also defined in XAML. Ribbon button commands are bound with corresponding commands and SfDataGrid is passed as CommandParameter.

XAML

The following code example illustrates the RibbonButton actions for the cut, copy and paste operation.

C#

The following screenshot illustrates the cut, copy and paste operation in SfRibbon.

C:\Users\Ganeshkumar L\Desktop\KB1.png

Figure 1: Cut, copy and paste operation in SfRibbon

Integrating SfDataGrid copy paste with ContextMenu

You can set ContextMenu for record cells in SfDataGrid using SfDataGrid.RecordContextMenu as illustrated in the following code example. Here, copy and paste operations in SfDataGrid is integrated with ContextMenu through commands. Also default CommandParameter of RecordContextMenu from SfDataGrid (namely GridRecordContextMenuInfo) is passed to commands.

XAML

The following code example illustrates the actions for cut, copy and paste operation.

C#

The following screenshot illustrates the cut, copy and paste operation in ContextMenu

C:\Users\Ganeshkumar L\Desktop\KB2.png

Figure 2: Cut, copy and paste operation in ContextMenu

Sample Link: CopyandPastebyContextMenu_WPF

To know more about CustomContextMenu in SfDataGrid refer to the following KB. http://www.syncfusion.com/kb/2422/how-to-enable-custom-context-menu-in-griddatacontrol

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3203 01/12/2015 07/10/2015 WPF SfDataGrid 4.5
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon