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

Disable copy and cut CommandDescriptor?

2 Answers 70 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
W
Top achievements
Rank 1
W asked on 25 Jul 2016, 01:04 AM

"RadSpreadsheet.CommandDescriptors.Copy.IsEnabled = false" is not work.

How to disable copy and cut in spread sheet?

2 Answers, 1 is accepted

Sort by
0
Nikolay Demirev
Telerik team
answered on 27 Jul 2016, 11:37 AM
Hello,

The command descriptors have internal logic for enabling and disabling the ribbon buttons. Maybe that is the reason why they can not be disabled by setting the IsEnabled property to false because after that they are enabled by the internal logic.

The Copy operation can be performed using several different inputs - RibbonButtons, Context menu, Key bindings.

If you want to disable the ribbon buttons, you could implement your custom property which can be bound to the IsEnabled property of the button. This way you will control when to enable or disable the ribbon button.

The same solution as for the Ribbon buttons is applicable for the context menu of the WorksheetEditor.

The last way copy values from the RadSpreadsheet is by the key combination Ctrl+C. You can disable it by setting empty command to the same key combination. You could use the following code snippet:
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);
    }
}


Regards,
Nikolay Demirev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
W
Top achievements
Rank 1
answered on 28 Jul 2016, 02:24 AM

Thanks a lot Nikolay!

You solved the problem perfectly!

Tags
Spreadsheet
Asked by
W
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
W
Top achievements
Rank 1
Share this question
or