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

Getting the UI Element in the copy cell operation

I need to intercept the copy cell operation so I can replace what is being copied onto the clipboard. In order to do this properly, I need to have access to the UIElement being displayed in the Cell, since the DataContext in the Cell is a custom object that I need access to.

There seem to be two points to hook into, one is the CopyGridCellContent event, one is by setting a custom GridCopyPaste object on the grid. Neither of these provides access to the Cell's UIElement.

For a bit more detail, the Row object has a double in a particular field, but when it is rendered in the UI, the renderer creates a more complex object that I need access to that exists only in the Cell's UIElement.

How can I do this?

A.

1 Reply

SP Shobika Palani Syncfusion Team January 21, 2019 03:53 PM UTC

Hi Avram, 
 
Thank you for contacting Syncfusion Support. 
 
We have analyzed your query to get UI element in copy cell operation and you can achieve this using CopyGridCellContent event as like following code snippet 
 
private void AssociatedObject_CopyGridCellContent(object sender, GridCopyPasteCellEventArgs e) 
{ 
            var copiedDataRow = this.AssociatedObject.RowGenerator.Items.FirstOrDefault(row => row.RowData == e.RowData) as DataRow; 
            //Row element of the copied row 
            var copiedRowElement = copiedDataRow.Element; 
 
            var copiedColumn = copiedDataRow.VisibleColumns.FirstOrDefault(col => col.GridColumn == e.Column); 
            //Column element of the copied cell 
            var copiedColumnElement = copiedColumn.ColumnElement; 
} 
 
Please find sample for the same from the following link 
Sample Link : 
 
Please get back to us, if you need any further assistance on this. 
 
Regards, 
Shobika. 


Loader.
Live Chat Icon For mobile
Up arrow icon