Because I got stuck I looked at the following example:
http://www.telerik.com/community/forums/wpf/gridview/copying-cell-content-problem.aspx
Using that example: When I go into edit mode for a cell, I can copy the cell's content. When I only select the cell without going into edit mode (still seeing a selection rectangle), it is called three times and in the end copies the entire row to the clipboard.
However, what I want is to copy only the current cell's content to the clipboard without having to go into edit mode (my grid happens to be read only). Bonus: can I get a context menu over the cell for copy? (without too much effort)
Thanks,
Chris
http://www.telerik.com/community/forums/wpf/gridview/copying-cell-content-problem.aspx
Using that example: When I go into edit mode for a cell, I can copy the cell's content. When I only select the cell without going into edit mode (still seeing a selection rectangle), it is called three times and in the end copies the entire row to the clipboard.
However, what I want is to copy only the current cell's content to the clipboard without having to go into edit mode (my grid happens to be read only). Bonus: can I get a context menu over the cell for copy? (without too much effort)
Thanks,
Chris
5 Answers, 1 is accepted
0

Christoph
Top achievements
Rank 1
answered on 11 Aug 2011, 07:32 AM
I came up with some sort of solution for Ctrl+C:
I don't really consider this to be elegant or intuitive (Cells copy mode should be working this way by default), but it works.
Context menu question still open.
Chris
void
PitGridView_CopyingCellClipboardContent(
object
sender, GridViewCellClipboardEventArgs e)
{
if
(CurrentCell !=
null
&& CurrentCell.Column == e.Cell.Column)
{
e.Cancel =
false
;
}
else
e.Cancel =
true
;
}
I don't really consider this to be elegant or intuitive (Cells copy mode should be working this way by default), but it works.
Context menu question still open.
Chris
0
Hello Christoph,
ClipboardCopyMode=Cells will always try to copy all the selected items, based on the value of the SelectionUnit property of RadGridView. If SelectionUnit=FullRow, RadGridView will copy whole rows, whereas if SelectionUnit=Cell RadGridView will copy individual cells.
From what I understand in your case, you have SelectionUnit=FullRow (the default), but would only like to copy one cell. What you can do is to either set SelectionUnit to Cell and change the way selection works, or keep using your workaround in the CopyingCellClipboardContent event.
Regarding the context menu question: I believe this example will help you get started. Even though it's for Silverlight, you can use the same code in your WPF application. Or you can find this example in the RadControls for WPF Demos application that was installed along with RadControls for WPF. Don't hesitate to let us know if you have any difficulties in implementing it in your application.
All the best,
Yavor Georgiev
the Telerik team
ClipboardCopyMode=Cells will always try to copy all the selected items, based on the value of the SelectionUnit property of RadGridView. If SelectionUnit=FullRow, RadGridView will copy whole rows, whereas if SelectionUnit=Cell RadGridView will copy individual cells.
From what I understand in your case, you have SelectionUnit=FullRow (the default), but would only like to copy one cell. What you can do is to either set SelectionUnit to Cell and change the way selection works, or keep using your workaround in the CopyingCellClipboardContent event.
Regarding the context menu question: I believe this example will help you get started. Even though it's for Silverlight, you can use the same code in your WPF application. Or you can find this example in the RadControls for WPF Demos application that was installed along with RadControls for WPF. Don't hesitate to let us know if you have any difficulties in implementing it in your application.
All the best,
Yavor Georgiev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0

Christoph
Top achievements
Rank 1
answered on 16 Aug 2011, 06:13 AM
Regarding the context menu - I already have one for the header (column visibility, also from the samples). What is the best way to have 'two different' context menus on the GridView?
Chris
Chris
0
Hello Christoph,
Maya
the Telerik team
In case you want to have both row and header context menus, you may follow the approach illustrated in this forum thread. If you want to apply specific logic depending on the underlying item or cell, you may handle the Opening event of the RadContextMenu and perform it inside.
Let me know in case you need any further assistance.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0

Christoph
Top achievements
Rank 1
answered on 16 Aug 2011, 09:16 AM
I went with a switch in the Opening event based on the type of cell the context menu was opened on.
Chris
Chris