6 Answers, 1 is accepted
If you set the SelectionMode to be Cell, then when user press "Ctrl+C" the content of the current selected cell will be copied.
Is this suitable for your scenario?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Also I need to be able to select the whole row not single cells (actually my Selection mode is Extended)
I am sorry, I meant the SelectionUnit property.
All the best,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I think I am going to set ClipboardCopyMode to None which will disable default copying at all and will hook CTRL+C keyboard gesture to my custom method that will grab the current cell value and put it in Clipboard. I already have the method. It is being called from context menu for the grid.
void
miCopyCell_Click(
object
sender, RoutedEventArgs e)
{
if
(
this
.CurrentCell ==
null
)
{
MessageBox.Show(
"No cell has been selected."
);
return
;
}
var text =
this
.CurrentCell.Value.ToString();
try
{
Clipboard.SetText(text);
}
catch
(System.Runtime.InteropServices.COMException)
{
System.Threading.Thread.Sleep(0);
try
{
Clipboard.SetText(text);
}
catch
(System.Runtime.InteropServices.COMException)
{
MessageBox.Show(
"Can't Access Clipboard"
);
}
}
}
Thank you for this remarks. You are right, you should implement your own copy functionality in that scenario.
Please keep in mind that this key combination is handled internally as RadGridView does provide support for copy-paste functionality and the corresponding shortcuts for it.
What you could do is to add a handler for KeyDown event as follows:
public
MainPage()
{
InitializeComponent();
this
.AddHandler(RadGridView.KeyDownEvent,
new
KeyEventHandler(OnKeyDown),
true
);
}
private
void
OnKeyDown(
object
sender, KeyEventArgs e)
{
if
(e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
{
// your logic
}
}
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Found an easier way to do it. All you have to do is attach an event handler on the radgridview for the CopyingCellClipboardContent event and check if the e.Cell == the currentcellinfo otherwise just sent e.Cancel to true