6

When I build my form on my machine it looks fine, but when it is compiled on a different computer the size of the form itself is wrong. Labels are moved around and things are no longer aligned properly.

How do I guarantee that everything will look the same on any computer?

I tried setting AutoScaleMode to none, and it helped a bit but then the labels were partially underneath the corresponding text boxes.

Servy
  • 202,030
  • 26
  • 332
  • 449
NMunro
  • 1,282
  • 4
  • 18
  • 33

3 Answers3

5

Either the font or the DPI differ.

And I've never really found a way to say AutoScaleMode = (most appropriate of font or dpi).

But try AutoScaleMode = DPI and AutoScaleMode = Font. One of them should work.

We never found a reliable way to handle this. Our workplace USED to enforce the DPI on all workstations, but that has since changed. The best way to handle it is to make sure you layout your controls with FlowLayoutPanel or TableLayoutPanels instead of absolute positioning of controls.

hometoast
  • 11,522
  • 5
  • 41
  • 58
  • If you go to Control Panel\Appearance and Personalization\Display you have the choice between 100%, 125%, and 150%. I'm assuming this changes the DPI. How would the font differ on different machines? – NMunro Nov 19 '12 at 16:08
  • You're right. That's the DPI; Microsoft just words it in a weird way in my opinion. You can change the system fonts used in dialogs etc. like [this](http://www.sevenforums.com/tutorials/1175-fonts-change.html) – hometoast Nov 19 '12 at 16:23
  • Is there a way to tell if they've changed DPI or font? My preferred solution would be a message box telling them to stop screwing with things. LOL – NMunro Nov 19 '12 at 16:55
0

I was having this issue recently and it turns out that compiling at 125% or the medium setting makes the binary immune to changes at either 100 or 150 percent. You still need to set the AutoScaleMode to None.

0

Even if the topic is over, my two cents since I was facing some same problem, the form had a different size (in my case bigger) but the controls where the same when fixed. I only solved it by giving the original form smaller dimensions than the control, and allow it to grow automatically.

I also applied the guidelines of this post (How to write WinForms code that auto-scales to system font and dpi settings?) but it didn't solve my problem.

Community
  • 1
  • 1