In my application I am using RichTextBoxes with readonly property set to True.
But the font size can still be changed using the mouse wheel and default windows keyboard shortcut for fontsize change (Ctrl+shift+ >/<).
How do I disable RichTextBox font size change?
To disable the key combinations of
Control+Shift+<orControl+Shift+>, you need to implement the following KeyDown event handler for your RichTextBox control:This code prevents the user from resizing the font in the given
RichTextBoxwith keyboard commands.To disable changing the font size by using Ctrl plus the mousewheel, the only way I know how to do this is to make a user
controlthat inherits fromRichTextBox.Once you have done that the only thing you need to do is override the
WndProcprocedure so that it effectively disables any messages when the scrollwheel is moving and the Ctrl button is pressed. See the code below for implementing aUserControlderived from theRichTextBox: