How to set font of control to a system font?

N

Noozer

I would like the font used on one of my forms to match whichever font the
user has selected in their display properties.

For example, I want the font on my textboxes to match the "menu" font. I
want the status bar on my form to use the "tooltip" font, like the Windows
Explorer does.

I don't see any simple method to say "mytextbox.font = font.menu" or
"myStatusbar.font = font.tooltip"

I'm sure that this is simple and I'm just not seeing it. How do I do this?

....and, as a secondary question, how can my application detect if the user
alters a Windows font/color setting while my application is running?
 
M

Mattias Sjögren

I don't see any simple method to say "mytextbox.font = font.menu" or
"myStatusbar.font = font.tooltip"

I'm sure that this is simple and I'm just not seeing it. How do I do this?

Check out the System.Drawing.SystemFonts class.

...and, as a secondary question, how can my application detect if the user
alters a Windows font/color setting while my application is running?

Handle the Microsoft.Win32.SystemEvents.UserPreferenceChanged event.


Mattias
 

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