Disable copy and cut CommandDescriptor?

3 posts, 0 answers
  1. W
    W avatar
    14 posts
    Member since:
    Apr 2016

    Posted 24 Jul Link to this post

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

    How to disable copy and cut in spread sheet?

  2. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 27 Jul Link to this post

    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.
  3. DevCraft banner
  4. W
    W avatar
    14 posts
    Member since:
    Apr 2016

    Posted 27 Jul Link to this post

    Thanks a lot Nikolay!

    You solved the problem perfectly!

Back to Top