设置表单最小尺寸 [英] Set form minimum size

查看:25
本文介绍了设置表单最小尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有相当大边框的 C# 表单.我想将最小大小设置为 (850, 760)(默认起始大小),但是当我尝试在表单属性菜单中设置该值时,它不断将其更改为 (850, 720).我尝试通过代码设置它如下:

I have a C# form with a sizable border. I'd like to set the minimum size to (850, 760) (the default starting size), but when I try to set the value in the form properties menu it keeps changing it to (850, 720). I tried setting it by code as follows:

this.minimumSize = new System.Drawing.Size(850, 760);

但是当我运行代码时,我仍然可以垂直缩小表单.有没有人对可能出现的问题有任何想法?

but when I run the code I can still shrink my form vertically. Does anyone have any ideas as to what the problem might be?

我使用两台显示器,一台标准 1280x1024,另一台宽屏 1366x768,这可能是问题吗?在这种情况下,有什么方法可以测试用户的显示器分辨率并基于此设置最小尺寸吗?

I'm using two monitors, one standard 1280x1024 and the other widescreen 1366x768, could that be the problem? In that case is there some way to test the user's monitor resolution and set the minimum size based on that?

推荐答案

许多在运行时运行的代码在设计时也处于活动状态.这为 Winforms 设计器提供了一个非常好的 WYSIWYG 用户界面,但它确实有一些不幸的副作用.包括让设计师崩溃并给你 Darn 的白屏.或者,如果您访问此网站的名称,将 VS 崩溃到桌面.

A lot of the code that runs at runtime is active at design time as well. That gives the Winforms designer a very nice WYSIWYG user interface, but it does have some unfortunate side-effects. Including crashing the designer and giving you the White Screen of Darn. Or crashing VS to the desktop if you trip this website's name.

这是一个这样的副作用,运行时代码将 MinimumSize 限制为 Screen.WorkingArea,并且在设计时也是如此.只需尝试输入 (0, 3000) 即可看到发生的情况.您可以通过在代码中分配属性来强制它.

This is one such side-effect, the runtime code limits the MinimumSize to the Screen.WorkingArea and does so at design time as well. Just try typing in (0, 3000) to see that happening. You can force it by assigning the property in code.

这篇关于设置表单最小尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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