Skip to content

How to append the new text in clipboard which is not available in DataGrid(SfDataGrid)?

Notifications You must be signed in to change notification settings

SyncfusionExamples/How-to-append-the-new-text-in-clipboard-which-is-not-available-in-DataGrid-SfDataGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

How to append the new text in clipboard which is not available in DataGrid(SfDataGrid)?

About the sample

This example illustrates how to append the new text in clipboard which is not available in DataGrid(SfDataGrid)?

By default, SfDataGrid copies the selected row or cell data in clipboard, you need to append the new text in clipboard which is not available in SfDataGrid can be achieve by overriding the CopyCells and CopyCellRow method in GridCutCopyPaste class.

dataGrid.GridCopyPaste = new CustomCopyPaste(dataGrid as SfDataGrid); 

public class CustomCopyPaste : GridCutCopyPaste 
{ 
 
    public CustomCopyPaste(SfDataGrid sfGrid) : base(sfGrid) 
    { 
    }    
 
    protected override void CopyCells(GridSelectedCellsCollection selectedCells, StringBuilder text) 
    { 
        base.CopyCells(selectedCells, text); 
        text.Insert(0, "\t"); 
    } 
 
    protected override void CopyCellRow(GridSelectedCellsInfo row, ref StringBuilder text) 
    { 
        base.CopyCellRow(row, ref text); 
        var DataTable = (dataGrid.ItemsSource as DataTable); 
        int index = DataTable.Rows.IndexOf((row.RowData as DataRowView).Row as System.Data.DataRow) + 1; 
        string value = "Row_" + index + "\t"; 
        text.Insert(0, value); 
    } 
}   

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to append the new text in clipboard which is not available in DataGrid(SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages