How do I disable Ctrl+S behavior in RadSpreadsheet and RichTextEditor of Winforms?

1 Answer 49 Views
RichTextEditor Spreadsheet
Kishore Kumar
Top achievements
Rank 1
Kishore Kumar asked on 09 Sep 2021, 04:37 PM

We have a customized save option and is implemented under the File --> Save (overridden) method. However, the default Ctrl+S is opening up the Savefiledialog and the users are enabled to save a copy. We need to restrict the save to the local disk. Any options on how to override all the possible save options?

 

Thanks,

Kishore

1 Answer, 1 is accepted

Sort by
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Sep 2021, 10:01 AM

Hello, Kishore,

RadSpreadsheet handles the user's input by its input behavior. If you want to handle pressing Ctrl+S and disable the default logic, you can use the following approach: 

        public RadForm1()
        {
            InitializeComponent();

            this.radSpreadsheet1.SpreadsheetElement.InputHandler = new CustomSpreadsheetInputBehavior(this.radSpreadsheet1.SpreadsheetElement);
        }
        
        public class CustomSpreadsheetInputBehavior : SpreadsheetInputBehavior
        {
            public CustomSpreadsheetInputBehavior(RadSpreadsheetElement spreadsheet) : base(spreadsheet)
            {
            }

            public override void ProcessKeyDown(KeyEventArgs e)
            {
                if (e.Control && e.KeyCode == Keys.S)
                {
                    return;
                }
                base.ProcessKeyDown(e);
            }
        }

As to the RadRichTextEditor control,  you can handle the CommandExecuting control and cancel any command that you don't want to be performed:

            this.radRichTextEditor1.CommandExecuting += radRichTextEditor1_CommandExecuting;

        private void radRichTextEditor1_CommandExecuting(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
        {
            if (e.Command is SaveCommand)
            {
                e.Cancel = true;
            }
        }
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
RichTextEditor Spreadsheet
Asked by
Kishore Kumar
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or