• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

changing the font size..

how do i change the font size of all the objects on a form

without writing for each object "<object>.font.size=<size>"

  • 2
1 Solution
If you set the forms font size at design time then all controls will inherit that size as you add them.

You can also "lasso" a group of controls (or select all with <Ctrl A>) and change thier font as a group.

At runtime, you're going to have to iterate thru the Controls collection changing the fonts as you go. Not all controls support a font size so you'll need a little bypass logic to skip control types that don't support font size property. Basic loop will be:

dim ctrl as object

for each ctrl in controls
  ctrl.fontsize = whatever
next ctrl

If you're dynamically resizing a forms' controls as the user changes rez, this is generally not a good idea. If you're doing it in response to an operator controlled selection, then that is better.


amirdAuthor Commented:
there is still a problem with the size of the contols that doesnt changed accordingly to the change in the font size
You didn't *ask* that! You asked: "how do i change the font size of all the objects on a form without writing for each object "<object>.font.size=<size>". You didn't mention resizing the objects!

Resizing, in theory, is not hard. You use a pair of const to remind your program of the Screen.Width and .Height that it was originally coded for. Then at runtime you compute the ratio of what you were originally set for to what you're running on right now. Iterate thru the controls and scale the .Left, .Top, .Width, and .Height appropriately.

Problem is that the users will generally perceive this behaviour as a *BUG* more than a *feature*. General opinion on "dynamic resize" is DON'T. The user is upping their rez to fit more on screen at once. If your program automatically grows to take more space this defeats the users wishes and is perceived as a *problem*.

Better to set minimum rez for your software to, say, 800x600 and make it look nice in that context. If the user pushes the rez to 1200,1024, ok, then that's *THEIR* choice and you'll still look nice with 800x600 screens.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now