views:

236

answers:

4

I have attached a screen shot : http://i.imgur.com/tU05T.png I have checked my DPI settings. they are 100%. I cant seem to find out why the test would be a differnt font size in the runtime application vs the designer.. Can anyone assist. I have tried googling, have have not come up with any meaningful links..

+2  A: 

The two shoots use different fonts, so you can't expect the alignment to match. Perhaps Windows 7 substitutes your selected font for something else. Can you force the font to make sure the same is used in both cases?

Brian Rasmussen
They are the same font.. but visually they are different ..i took the screen shot with the application running in debug mode over visual studio... !!!
niq
Obviously they are not the same. Look at the I and the g. My guess is that font substitution occurs.
Brian Rasmussen
How does that occur.. How can i force the application to render the fonts the same way as the designer does?? its really annoying. This doenst happen in any other version of windows except 7
niq
It looks like Windows 7 is using Verdana while your VS 2008 is using Calibri. These are different fonts with different spacing requirements. It's possible that the app is using a system default font that is different from the display font in VS 2008.
Joel Etherton
See R Bemrose's answer, which may have the details.
Brian Rasmussen
+3  A: 

Windows 7 uses Segoe UI as its default interface font. If you haven't explicitly set a font on your form or controls, that's what you're going to get.

This is not the case in previous versions of Windows, which used Microsoft Sans Serif. This is also what Visual Studio displays.

Source

Edit: Although that source doesn't say that Windows will automatically set the font to Segoe UI, so I'm not really sure why it's changing. I'm not on a Windows 7 machine at the moment, so I can't see what my machine does.

R. Bemrose
I see.... Ye it is indeed changing it to Segoe UI. I have to explicitly change each form to use a particular font, which is what i'm trying to avoid..
niq
+2  A: 

To circumvent such issues with different fonts on different Windows versions, or to deal with environments where the user has specified to use large fonts, it is best to use a layout manager to dynamically resize your controls.

Specifying a certain font is not a good idea, because then the GUI will not match the platform standard and you cannot be certain that the font is present (Segoe UI is not available on Windows XP for example). In addition, it doesn't solve issues like large fonts (or different string lengths in localized versions).

In Windows Forms an automatically adjusting layout can be accomplished by using e.g. a TableLayoutPanel. You will find a sample for that on MSDN:

Walkthrough: Arranging Controls on Windows Forms Using a TableLayoutPanel

0xA3