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

A

Andrus

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(MouseEventArgs e)
{
base.OnMouseWheel(e);
Settings.Default.TextBoxFont = new SerializableFont(Font);
}
}
 
M

michel.desangles

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(MouseEventArgs e)
        {
            base.OnMouseWheel(e);
            Settings.Default.TextBoxFont = new SerializableFont(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.ZoomFactor;).

Michel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top