471,319 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

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

Aug 5 '08 #1
1 4550
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(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
Aug 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Carlos García-Carazo | last post: by
2 posts views Thread by Kevin L | last post: by
1 post views Thread by Terry Olsen | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.