控件在一台计算机上的位置不同 [英] Controls are positioned differently on one computer
问题描述
我们有一个Windows表单,除了一个以外的所有计算机上看起来如下:
We have a Windows form which looks as follows on all computers except one:
所有计算机都运行Windows 7,32位,具有相同的屏幕分辨率,并将控制面板的"外观"和"个性化"\\"显示"设置为"较小 - 100%(默认)"。
Windows窗体是在带有.NET Framework 4.0的Visual Studio 2010中开发的。
有人有一个想法,为什么表格在特定的计算机上看起来如此不同?
All computers run Windows 7, 32 bit, have the same screen resolution, and have Control Panel\Appearance and Personalization\Display set to "Smaller - 100% (default)".
The Windows form was developed in Visual Studio 2010 with .NET Framework 4.0.
Does somebody have an idea, why the form looks so different on that particular computer?
推荐答案
嗨pappasa,
Hi pappasa,
此计算机的DPI是否与其他电脑?我担心这个问题与不同的DPI有关,
尝试设置
AutoScaleMode 表单属性为
Dpi 而不是Font:
Is the DPI of this computer inconsistent with other computers? I'm afraid the issue is related to different DPIs,
try to set the
AutoScaleMode property of your form to
Dpi instead of Font:
然后在Program.cs中更改一些代码:
Then change some code in the Program.cs:
class Program
{
[STAThread]
static void Main()
{
if (Environment.OSVersion.Version.Major >= 6)
SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
}
最好的问候,
Frankie
这篇关于控件在一台计算机上的位置不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!