This is a migrated thread and some comments may be shown as answers.

RadGridView Pasting Get source cell

3 Answers 17 Views
This is a migrated thread and some comments may be shown as answers.
Anatol
Top achievements
Rank 1
Anatol asked on 06 Sep 2019, 03:39 AM

Hello

I use c# wpf telerik RadGridView and I have problem with Pasting. RadGridView`s cells contain my special custom type:

class Place

{

   int id;

   string name;

}

I need to get source cell in PastingCellClipboardContent to read Place.id:

private void radGridView1_PastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e){

if (e.Cell.Column.UniqueName == "Place"){

   //here i need source cell

}

How can I get it?

Thanks

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 10 Sep 2019, 06:14 AM

Hello Anatol,

To achieve your requirement, you can get the data context of the cell using its Item property, and then find the Place's id from the data context's properties. Here is an example:

private void radGridView1_PastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e){

	if (e.Cell.Column.UniqueName == "Place")
	{
		var item = (MyModel)e.Cell.Item;
		var id = item.Place.Id;
	}
}

I also attached an example showing this approach. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Anatol
Top achievements
Rank 1
answered on 11 Sep 2019, 02:30 AM

Thanks for reply!

Sorry, may be I `ve discribed my problem wrongly. I would like to get access to SOURCE cell, not target cell.

var item = (MyModel)e.Cell.Item; //It`s a tareget cell, which will be replaced with new data from source cell

I found out I can get source data from e.Value, but it`s only object,  it contains only place.name, but doesn`t contain my place.Id.

 

0
Martin Ivanov
Telerik team
answered on 11 Sep 2019, 07:23 AM

Hello Anatol,

No worries. The mistake here is main.

The e.Value property from the PastingCellClipboardContent event arguments contains only the copied data string because during the copy of a cell only this is saved.  The reason behind this behavior is that the data should be readable from any application that supports pasting and usually those application doesn't have information for the RadGridView's cell or the underlying business object. 

To achieve your requirement, you can use also the copy events of RadGridView (Copying, CopyingCellClipboardContent and Copied) where you can save information for the copied cell and use it in the PastingCellClipboardContent event.

Regards,
Martin Ivanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Anatol
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Anatol
Top achievements
Rank 1
Share this question
or