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

2 questions on SfDataGrid

Thread ID:





129776 Apr 3,2017 11:37 AM UTC Apr 4,2017 04:24 PM UTC WPF 1
Tags: SfDataGrid
Asked On April 3, 2017 11:37 AM UTC


I'm trying to accomplish a copy - paste and color changing in an SfDataGrid.
1. Copy - Paste between 2 SfDataGrids

I have 2 SfDataGrids, A and B.

I want to select a row from A and by pressing a button to copy the  row and paste it at B.

I'm not sure if I'm missing something with the Copy / Paste functions.

Data selectedRow = ( Data )A.SelectedItem;

if( selectedRow != null )


2. I need to change row background and foreground colors upon selecting a row and then pressing of a button.


How can I accomplish that?




Muthukumar Kalyanasundaram [Syncfusion]
Replied On April 4, 2017 04:24 PM UTC

Hi Dov, 

Thank you for contacting Syncfusion support. 

We have analyzed your query. 

Query 1:  “Copy & paste the selected item between two SfDataGrid ”. 

If you want to copy and paste the selected item between two datagrid, you can achieve your requirement by setting GridCopyPaste.Copy() and GridCopyPPaste.Paste() method. When we copy and paste the selected item in another grid, you need to specific index to be paste the record. Could you please refer the below code snippet and sample in below location, 
Code Snippet:  

private void Button_Click(object sender, RoutedEventArgs e) 
    var currentCell = gridA.SelectionController.CurrentCellManager.CurrentCell; 
    var record = this.gridA.GetRecordAtRowIndex(currentCell.RowIndex); 
    this.gridA.SelectedItem = record;             
    // need to specific the index to paste the record in grid 
    this.gridB.SelectionController.MoveCurrentCell(new Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex(currentCell.RowIndex,currentCell.ColumnIndex),true); 

Query 2:  To change row background and foreground colors upon selecting a row and then pressing of a button 
You can achieve your requirement by enabling RowSelectionBrush and SelectionForegroundBrush property. Please refer the below code snippet, 

private void Button_Click_1(object sender, RoutedEventArgs e) 
    gridB.RowSelectionBrush = new SolidColorBrush(Colors.Bisque); 
    gridB.SelectionForegroundBrush = new SolidColorBrush(Colors.Red); 


Please let us know if you have any query. 

Muthukumar K 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the 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