Visual Studio 2008 Windows 窗体设计器如何兼容 QVGA 和 VGA?

发布于 2024-10-03 02:57:17 字数 261 浏览 0 评论 0原文

在 Visual Studio 2008 中使用智能设备项目时,如果我使用窗口窗体设计器向窗体添加控件,那么当程序实际运行时,无论设备具有 QVGA 还是 VGA,这些控件都将显示在正确的位置屏幕。但是,如果我在代码中手动添加控件而不使用设计器,那么我需要在运行时检查代码是否具有 VGA 屏幕或 QVGA 屏幕。如果它是 VGA 屏幕,我必须为手动添加的每个控件将 x、y、宽度和高度乘以 2。为什么只有在不使用设计器的情况下添加的控件才需要这样做?

我刚刚在第一个答案下面添加了一条评论。

In Visual Studio 2008 when working with a Smart Device project, if I use the Window Forms Designer to add controls to a form, then the controls will be displayed in the correct place when the program is actually running whether the device has a QVGA or VGA screen. However if I add controls to the form in my code manually without using the Designer, then I need have my code check at run time whether the device has a VGA screen or a QVGA screen. If it is a VGA screen I have to multiple the x, y, width, and height by 2 for each control added manually. Why is that only necessary for controls added without using the designer?

I just added a comment below the first answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眉目亦如画i 2024-10-10 02:57:17

由于 Designer.cs 中的这些属性,在设计时添加的控件在首次绘制时会自动缩放:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;

当您在运行时动态添加控件时,您需要执行自己的缩放。它并不理想,但这就是它的工作方式。

Controls that are added at design time are autoscaled when first drawn, due to these properties in the designer.cs:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;

When you dynamically add controls at runtime you'll need to perform your own scaling. Its not ideal, but its just the way it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文