Category / Section
How to disable the shortcuts to the WinForms SyntaxEditor (EditControl) in the child form so that the parent form can preview them?
1 min read
Shortcut keys
This process involves the following steps.
1. Capture the EditControl's ContextMenu and remove the ShortCut key (for example F5) from the EditControl's ShortCuts, since this functionality will not be required anymore. For information on how to do this, please refer to the KB article – ‘How do I disable keyboard shortcuts for the EditControl?’ which may be accessed from this link : https://www.syncfusion.com/Support/article.aspx?id=10334
2. Override the ProcessCmdKey() method in the MDI parent form to capture the F5 key. This ensures that F5 ShortCut is previewed only in the MDI parent form and not in the EditControl on the MDIChild form.
C#
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { const int WM_KEYDOWN = 0x100; const int WM_SYSKEYDOWN = 0x104; if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) { switch(keyData) { case Keys.F5: MessageBox.Show("F5 Captured by MDI Parent Form"); break; // and any other key that needs to be captured } } return base.ProcessCmdKey(ref msg,keyData); }
VB
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean Const WM_KEYDOWN As Integer = &H100 Const WM_SYSKEYDOWN As Integer = &H104 If (msg.Msg = WM_KEYDOWN) OrElse (msg.Msg = WM_SYSKEYDOWN) Then Select Case keyData Case Keys.F5 MessageBox.Show("F5 Captured by MDI Parent Form") ' and any other key that needs to be captured End Select End If Return MyBase.ProcessCmdKey(msg,keyData) End Function
Reference link: https://help.syncfusion.com/windowsforms/syntaxeditor/editing