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

Getting the UI Element in the copy cell operation

Thread ID:

Created:

Updated:

Platform:

Replies:

142111 Jan 21,2019 12:52 AM UTC Jan 21,2019 03:53 PM UTC WPF 1
loading
Tags: SfDataGrid
Avram M
Asked On January 21, 2019 06:47 AM UTC

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.

Shobika Palani [Syncfusion]
Replied On 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. 


CONFIRMATION

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

;