How to save font change by ctrl+mouse wheel in RichTextBox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrus

    #1

    How to save font change by ctrl+mouse wheel in RichTextBox

    I need to save font selected by user by Ctrl+MouseWheel in Winforms
    RichTextBox.

    I tried override below but this does not remember font: in this method
    Font.Size property
    seems to be always *initial* Font size when RichTextBox is created, *not*
    the font size set by ctrl+mouse wheel.

    How to find the font size set by Ctrl+Mouse wheel ?

    Andrus.

    partial class MyRichTextBox : RichTextBox
    {
    protected override void OnMouseWheel(Mo useEventArgs e)
    {
    base.OnMouseWhe el(e);
    Settings.Defaul t.TextBoxFont = new SerializableFon t(Font);
    }
    }

  • michel.desangles@gmail.com

    #2
    Re: How to save font change by ctrl+mouse wheel in RichTextBox

    On 5 août, 19:33, "Andrus" <kobrule...@hot .eewrote:
    I need to save font selected by user by Ctrl+MouseWheel in Winforms
    RichTextBox.
    >
    I tried override below but this does not remember font: in this method
    Font.Size property
    seems to be always *initial* Font size when RichTextBox is created, *not*
    the font size set by ctrl+mouse wheel.
    >
    How to find the font size set by Ctrl+Mouse wheel ?
    >
    Andrus.
    >
        partial class  MyRichTextBox : RichTextBox
        {
            protected override void OnMouseWheel(Mo useEventArgs e)
            {
                base.OnMouseWhe el(e);
                Settings.Defaul t.TextBoxFont = new SerializableFon t(Font);
            }
    >
    >
    >
    }- Masquer le texte des messages précédents -
    >
    - Afficher le texte des messages précédents -
    I seem to have misread your question (and forgot to send the answer at
    the same time, but both errors should cancel each other out).

    When you Ctrl-Wheel inside a RichTextbox, you're not changing the
    font, you're only changing the property "ZoomFactor " of the
    RichTextbox. So you should be able to save that property to your
    Settings and bind it back when necessary (it seems that the zoom
    factor is just that, a zoom factor, so when the factor is 2, the font
    is twice its normal size. Not sure though, just a visual guess, but
    maybe you could use something like : myFont.Size = myFont.Size *
    myRTB.ZoomFacto r;).

    Michel

    Comment

    Working...