Click here to Skip to main content
15,069,020 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
I use Microsoft Visual Studio 2010 on a 64bits Windows 7 machine which has a screen monitor with 1080p resolution. I designed a window with the Designer in MS VS 2010. Looked good on that machine.

Now I try to run this project on my laptop (also MS VS 2010 and Windows 7 64bits), which has probably a different system font and a different screen resolution.

This is the result:[^] (not talking about the red lables)

I searched the internet for a fix, but nothing seems to help Also tried to edit some properties and changing the fonts to systemfonts in code. No luck.

Why does this happen? What's the fix for this? Why doesn't the window/controls resize automatically to fit everything?

You will never have this condition om different screens if you design the UI layout properly. Main thing here is to avoid any absolute positioning and sizing. Everything should be docked, basically. Please see my past answers:
Zom Out malfunctions when Screen resolution changes[^],
a rudimentary code sample here: how to dock button so that it can adjust with the form[^].

QuantumHive 8-Feb-13 15:20pm
Thanks, I will take a look at this when I get back on my PC and see if it would work out and leave feedback here.
You are welcome. And please don't forget to accept the answer formally (green button), because this is really a way to go.
Windows forms controls do autosize, that's the problem. You see how everything is bigger? It's because teh screens are different...
They autosize to fit their content - so if a font on your desktop shows larger on the lappie, the the space allocated to it in your form also increases. And different PC's can have different default font sizes...
What you are asking for is that the size of the controls stay the same, and the font adjusts to fit the controls - which doesn't happen in WinForms, but does in WPF, so one solution is to re-write in that. (Nasty!)

A simpler solution might be: highlight your labels in the designer, and press the "send to back" button on the toolbar.
QuantumHive 8-Feb-13 14:53pm
Okay, that would work for the label maybe (although it's not an elegant solution), but what about the image?
All I want is that every content I've designed on my PC looks the same on every other machine. I want an elegant fix that resizes and adjusts every control object so that it would look relatively the same on every other PC, laptop and whatever screen resolution or system fonts they may use.
Also notice that even Visual Studio Designer changes everything, now I can't continue to work on my laptop because I'm afraid this will mess up everything when I continue on my PC.
OriginalGriff 8-Feb-13 15:00pm
If you want everything to resize then you have little option but WPF I'm afraid.
Images can be dealt with - they have a SizeMode property if you are using a picture box - but if you look at your screen grab that not the only thing that has changed size. And one of those looks suspiciously XP not Win7 (from the close box), which means they could end up quite different.
QuantumHive 8-Feb-13 15:14pm
I still don't get it. Why is this so complicated and what would I have to do with WPF? I mean, there are tons of applications for Windows that are used by billions of people all over the world with all kinds of different machines and settings. Here for example, the GIT GUI window looks relatively the same on my laptop as it does on my PC: How do developers fix this and work with it while designing an application? I mean, Microsoft must have come with a solution for this right? I mean come on, we are living in the year 2013, why would this be so hard to fix?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900