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

Customize copy, prevent cut & paste

2 Answers 390 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 11 Sep 2018, 08:35 PM
I am trying to figure out how to replace the copy command with my own version that can copy the row/column headers, as well as prevent cut and paste. In other controls I handled PreviewCanExecute and PreviewExecuted, but those don't seem to get triggered here. I tried to replace the editor.Commands.Copy command but it is readonly. Same with the command descriptors.

2 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 14 Sep 2018, 06:13 PM
Hi Steve,

Disabling the key bindings for cut and paste can be done by registering an empty command for the KeyBindings collection of the active editor:

this.radSpreadsheet.ActiveSheetEditorChanged += this.RadSpreadsheet_ActiveSheetEditorChanged;
  
private void RadSpreadsheet_ActiveSheetEditorChanged(object sender, EventArgs e)
{
    if (this.radSpreadsheet.ActiveWorksheetEditor != null)
    {
        this.radSpreadsheet.ActiveWorksheetEditor.KeyBindings.RegisterCommand(new DelegateCommand(p => { }), Key.C, ModifierKeys.Control, null);
    }
}

If you are using the UI of RadSpreasheet, you might need to also disable the buttons. You can achieve that by directly modifying the XAML of the control. Here is how such a button looks like in the XAML code:

<telerik:RadRibbonButton Command="{Binding Path=Cut.Command}"  IsEnabled="{Binding Path=Cut.IsEnabled}" ... />
  
  ...
  
<telerik:RadMenuItem Header="Cut" Command="{Binding Path=Cut.Command}" Visibility="{Binding Path=Cut.IsEnabled, Mode=TwoWay, Converter={StaticResource BoolToVisibilityValueConverter}}">
 ...
</telerik:RadMenuItem>

To customize the way the content is copied, you will need to create a custom command descriptor for the Paste command. I am attaching an example to show how this can be achieved.

Hope this is helpful.

Regards,
Tanya
Progress Telerik
Get quickly 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
Prashant
Top achievements
Rank 1
answered on 21 Jan 2020, 04:17 PM

Hi Tanya,

How do we completely disable CutCopyPaste functionality for the radspreadsheet.

 

Thanks

Prashant

Tags
Spreadsheet
Asked by
Steve
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Prashant
Top achievements
Rank 1
Share this question
or