Designer根据屏幕大小更改表单大小 [英] Designer changes form-size depending on screen size

查看:111
本文介绍了Designer根据屏幕大小更改表单大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我的视觉工作室专业版2017有问题。我在办公室编程,我也在家办公室编程。当我在家庭办公室编程时,我使用远程桌面连接。我的问题是Visual Studio Windows窗体设计器
自动更改窗体的大小。即使我使用TeamViewer,Visual Studio Designer也缩小了我的From,因此按钮之类的元素甚至不再可见了。

i have a problem with visual studio professional 2017. I do programm in my office and i also do programm at my home office. While i do programm in my home-office i use a remote desktop connection. My problem is now that the Visual Studio Windows Forms Designer changes the size of my forms automatically. Even when i use TeamViewer the Visual Studio Designer shrinks my From so that some elements like buttons aren`t even visible anymore.

我的任务是now:有没有选项告诉Visual Studio Windows窗体设计器保持窗体大小与屏幕大小无关?

My questin is now: is there any option to tell the Visual Studio Windows Forms Designer to keep the forms size indipendent from the screen-size?

谢谢: - )

推荐答案

嗨Stewie,

Hi Stewie,

问题似乎与两个屏幕的不同DPI有关,尝试将表单的
AutoScaleMode 属性设置为 Dpi 而不是字体:

It seems the problem is related to different DPI of the two screens, 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


这篇关于Designer根据屏幕大小更改表单大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆