2X faster development
The ultimate WPF UI toolkit to boost your development speed.
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. C# 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) { base.PasteToRows(clipboardrows); return; } //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.
This page will automatically be redirected to the sign-in page in 10 seconds.
Hello. This code still works in .net 5.0??, I am trying to reproduce the example but is not working.