.Net 控制计算机之间大小的变化
我有一个奇怪的问题,我需要弄清楚如何解决,
过去几周我一直在我的笔记本电脑上开发一个项目,但是当我在其中一台工作电脑上打开程序时,很多控件都消失了尺寸错误和重叠等,
机器之间的差异是这样的:
笔记本电脑:
Windows 7 Pro; 显示 - 1920*1040; 视觉工作室2008; .net Framework 3.5
工作桌面:
windows xp pro; 显示:1024*768; 视觉工作室2008; .net框架3.5;
为了更好地描述问题,我有一个面板,我将其设置为 300px 宽,其中有一个标签,其中包含日期和日期,格式为 mm-DD-yyyy,使用 arial 和 8 号字体。
在笔记本电脑上,一切都完美契合,但在台式机上,面板似乎更小,并且标签仅显示一半的文本。
这只是众多问题之一,另一个问题是颜色系统。控制系统之间的颜色似乎完全不同(尽管我认为这是 win7 与 xp 的问题)
我能做些什么来解决这个问题? 是windows版本问题吗? (我的笔记本电脑上有一台 vmware 机器,所以我可以在其中进行编码和设计)
这是显示问题吗? - 这对我来说是一个大问题,因为我只有一台笔记本电脑,我认为这个问题可能会导致我最近在大学的作业中损失分数(我在笔记本电脑上编码,直到今天才在台式机上打开 - 所以不知道这个问题)
编辑:我已经找到了针对我的特定问题的某种解决方案,我发现我的笔记本电脑在针对视障人士的 dpi 设置上工作在 125%(不知道如何..),所以我将其重置回 100%或 96Dpi 这解决了我的问题,在与我认识的其他几个开发人员聊天后,他们说他们倾向于设计 96 dpi,同时在文本周围留一点空白以确保安全。但他们不太倾向于使用 C#,主要是使用 QT 框架在 C++ 中编写代码。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您工作站中的视频适配器具有不同的每英寸点数设置。表单会自动重新调整大小以适应这种情况。
当您交付产品并且它将在客户的计算机上运行时,也会发生这种情况。更改窗体的 AutoScaleMode 属性并不能解决问题,这只会在控件中产生剪切文本。确保您的表单设计能够适应布局变化。 Dock、Anchor、TableLayoutPanel、FlowLayoutPanel、针对困难情况的 Resize 事件。并确保控件继承其容器的 Font 属性(在“属性”窗口中不是粗体)
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)
确保您可以在 Visual Studio 中调整面板的大小,并且其中的所有控件都可以正确地重新定位和调整大小。您可以使用锚点来实现此目的,或者您应该使用
TableLayoutPanel
控件而不是常规Panel
。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 regularPanel
.更改 AutoScaleMode 设置。
Change your setting for AutoScaleMode.