.Net controls changing size between computers

2019-02-10 08:42发布

I have a wierd problem that i need to work out how to resolve,

I have spent the last couple of weeks working on a project for work on my laptop, but when I open the program on one of the work pcs alot of the controls are the wrong size and over lap etc,

the differences between the machines is this:

Laptop:

Windows 7 Pro; Display - 1920*1040; Visiual Studio 2008; .net framework 3.5

Work Desktop:

windows xp pro; display: 1024*768; visual studio 2008; .net framework 3.5;

to discribe the problem better, i have a panel which i have set to be 300px wide, which has a label inside with the day and the day in the mm-DD-yyyy format, using arial and size 8 font.

On the laptop it all fits perfectly but on the desktop the panel seems smaller and the label only displays half the text.

That is just one of many problems, another is with colour system.control seems to be a completly different colour between systems (althoug I figure that to be a win7 vs xp problem)

What can I do to fix this? is it a windows version problem? (I have xp on a vmware machine on my laptop so i could code and design in that)

is it a display problem? - this is a big problem for me as i only have 1 laptop and I think this problem could have caused me mark loss on my recent assignment for Uni (I coded on laptop and never opened on a desktop untill today - so had no idea of this problem)

EDIT: I have found a solution of sorts for my particular problem, I discovered that my laptop was working on 125% on the dpi settings for visually impaired (no idea how..) so I have reset it back to 100% or 96Dpi Which has fixed my problems, and after chatting to a couple of other developers I know, they say that they tend to design for 96 dpi while leaving a little bit of white space around text to be safe. but then they don't tend to use c# much and mainly code all in c++ using QT framework.

3条回答
欢心
2楼-- · 2019-02-10 09:09

Ensure you can resize your panel in Visual Studio with all of the controls inside it being repositioned and resized properly. You can use anchors to achieve this, or perhaps you should use a TableLayoutPanel control instead of a regular Panel.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-10 09:19

The video adapter in your workstation has a different dots-per-inch setting. The form automatically rescales itself to accommodate that.

This is going to happen as well when you ship your product and it will run on the client's machine. Changing the form's AutoScaleMode property is not a fix, that will just produce clipped text in the controls. Make sure you form design is resilient to layout changes. Dock, Anchor, TableLayoutPanel, FlowLayoutPanel, the Resize event for tough cases. And make sure the controls inherit their container's Font property (not bold in the Properties window)

查看更多
三岁会撩人
4楼-- · 2019-02-10 09:26

Change your setting for AutoScaleMode.

查看更多
登录 后发表回答