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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to copy one row and paste it into all the selected rows like Excel in the SfDataGrid?

Platform: WPF |
Control: SfDataGrid
Tags: copypaste

In SfDataGrid, by default you can copy one row and paste it into another row. When you need to copy one row and paste it into the selected rows, you can override GridCutCopyPaste. GridCutCopyPaste class consists of many overrides to customize copy paste operations. To achieve the above requirement, you can override PasteToRows (object clipboardrows) as in the following code example.


this.sfdatagrid.GridCopyPaste = new CustomCopyPaste(sfdatagrid);
public class CustomCopyPaste : GridCutCopyPaste
    public CustomCopyPaste(SfDataGrid sfgrid)
        : base(sfgrid)
    protected override void PasteToRows(object clipboardrows)
        var data = (IList)clipboardrows;
        //Gets the ClipbordText and check if the clipboard text is more than one row
        //means call the base.
        if (data.Count > 1)
        //Gets the Selected records for paste the copied row.
        var selectedrecord = this.dataGrid.SelectedItems;
        for (int i = 0; i < selectedrecord.Count; i++)
            var selectedRecords = selectedrecord[i];
            // Calls the PasteToRow method with copiedrecord and selectedrecord
            PasteToRow(data[0], selectedRecords);

Sample Links:






2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment
Mar 10, 2021

Hello. This code still works in .net 5.0??, I am trying to reproduce the example but is not working.


Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile