I have a grid set with SelectionMode="Multiple".
If the user is on a cell that holds a time value, and copies that to the clipboard, then uses the arrow key to move down one row, he is now on the time cell right below. When he pastes, nothing appears to happen. He has to click in the cell first. I think what is actually happening is that the grid is trying to paste the contents into the first cell in the row. I can see in the demo that if the grid's selection unit is set to cell instead of row, then pasting works "normally".
How do I fix this? I tried handling the PastingCellClipboardContent event, but couldn't see how to redirect the paste towards the cell that actually has the focus.
4 Answers, 1 is accepted
In PastingCellClipboardContent event, you could find the currently focused cell using RadGridView.CurrentCellInfo. For example if your time field is "Established", you may use the following logic in your case:
sender, GridViewCellClipboardEventArgs e)
Club currentSelectedItem = (sender
Club copiedSelectedItem = e.Cell.Item
currentSelectedItem.Established = copiedSelectedItem.Established;
I have prepared a sample project. Could you please review it and if this is not the case, could you change it appropriately and send it in a separate support ticket? Could you please as well specify what the demo that you are referencing is? This way we would suggest you an approach, appropriate for your case. All the best,
the Telerik team
Let's say I have a column "Call Time", and on row 0 it has a value of 9:00 AM. I copy that, and use the arrow key to move down one row and paste. In the PastingCellClipboardContent event I can see that e.Value is "9:00 AM". So that's what I need. I need to paste that directly into the current cell on row 1 - not the first cell, but the current one, which is the call time cell for that row. Can you modify the code you gave me to do that? I can't see how to do it, without hard-coding a case for every column, or perhaps using reflection, neither of which I should have to do. I really shouldn't have to be handling this event at all, in my opinion.
Let me provide you with more information about our copy/paste mechanism. When SelectionUnit is FullRow the grid will copy and paste whole rows. Contrary, when SelectionUnit is Cell the grid will paste and copy only selected cells. Also, when pasting, the pasting operation begin from the first selected unit.
I believe that the confusion come from the fact that Multiple selection mode is used. When you use navigation in conjunction with Multiple selection, selection is not modified by navigation - for example, moving to the next row will not select the next row.
Having this in mind, when you copy the first cell and then move to the cell below it, the latter cell will not become selected. This means that if you try to paste some content the pasting will begin from the first selected cell, not from the one that currently has focus.
This behavior is consistent no matter what mode is being used. Have you considered using Extended selection mode?
All the best,
the Telerik team
When I was observing the cell text being pasted only into the first column, of course what I was seeing was Telerik assuming that the clipboard contents contained an entire row (or rows), then pasting into the first column, then stopping because there is no additional data following a space or a tab, as there would be had I just copied an entire row's contents into the clipboard.
I've gone ahead and implemented a hard-coded workaround along the lines of what you provided.