Hi,
I have used PastingCellClipboardContent event on a wpf radgridview in order to convert the value pasted to a value in a combobox as described in: http://docs.telerik.com/devtools/wpf/controls/radgridview/clipboard/pasting.html
My grid has definition:
ClipboardCopyMode="Cells"
ClipboardPasteMode="Cells"
However, when copying a cell, then adding a new row and then trying to paste the content, this event does not fire (and produces very odd behaviour in the grid, but that's besides the point).
Any ideas?
Thanks.
7 Answers, 1 is accepted
ClipboardPasteMode property provides an option for inserting an item on pasting (setting it to "InsertNewRows"). Is that what you are trying or you are inserting new items in another way ?
Regards,
Maya
Telerik
No, my grid has definition
My grid has definition:
ClipboardCopyMode="Cells"
ClipboardPasteMode="Cells"
I'm using AddingNewDataItem to add a new row.
Could you try setting the pasting mode so that it inserts new items and verify whether it behaves as you require ?
Regards,
Maya
Telerik
No, it doesn't work.... I'm getting an exception "Cell is not valid". I think that the grid is trying to create a new row that's not what I need.
I don't want paste to create a new row. Also, after changing the definition, regular paste stopped working (from cell to cell).
I want paste to a cell to copy the value that I copied from a cell before a new row was created. If this event is supposed to be raised upon paste on a cell, why not after a row is added?
I just need copy paste to work from cell to cell on different rows, whether it's an existing row or a new row....
Could you take a look at the project attached and let me know how it should be modified so that it follows your scenarios ? What are the steps I need to follow in order to get similar behavior as the one on your side ?
Regards,
Maya
Telerik
Hi Maya
Thanks for your reply. I reproduced the issue in the project.
Modify the Grid definitions like this:
<telerik:RadGridView Grid.Row="0"
Name="clubsGrid"
ItemsSource="{Binding Clubs}"
AutoGenerateColumns="False"
ClipboardCopyMode="Cells"
ClipboardPasteMode="Cells"
CanUserInsertRows="True"
GroupRenderMode="Flat"
NewRowPosition="Bottom"
AddingNewDataItem="clubsGrid_AddingNewDataItem"
PastingCellClipboardContent="clubsGrid_OnPastingCellClipboardContent"
SelectionUnit="Cell"
Margin="5">
Add to MainWindow.xaml.cs:
private void clubsGrid_AddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
var club = new Club();
e.NewObject = club;
}
private void clubsGrid_OnPastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
{
//here you can see that if I copy/paste a cell regularly - the event is reached
//follow this scenario:
//1. Copy a cell
//2. Add new row
//3. Try to paste to a cell in the new row
//4. You will not reach this event
MessageBox.Show("Reached Event!!");
}
To reproduce:
1. Copy a cell on one row
2. Paste to cell in another row (same column) - you can see the event OnPastingCellClipboardContent is reached
3. Now copy a cell again
4. Add a new row
5. Try to paste to a cell in the new row
6. You will see the event is not reached
Thanks so much!!
That would be the expected behavior since you are not pasting on the grid but rather on a TextBox (when inserting a new items, the first cell is in edit mode and the editing element is a TextBox). It on the other hand handles the pasting.
You can check out one of the following links for further reference (link 1, link 2, link 3).
Regards,
Maya
Telerik