Windows 窗体在左侧辅助监视器上时无法调整大小
我在使用 C# 编写的 Windows 应用程序时遇到了最奇怪的问题。
虽然绝对没有什么特别之处,但主窗口在主显示器和任何辅助显示器(当后者配置为位于主显示器的右侧时)都可以完美运行。但是,当我将辅助屏幕重新配置为放置在主显示器的左侧时,我(和其他人)不再可以更改表单的大小。鼠标指针不会变为“NW-SE-箭头”,单击“&”也不会变为“NW-SE-箭头”。拖动边缘会对窗口大小的任何变化做出反应。
做一些额外的实验似乎只有当我将表单的 AutoSizeMode 设置为 GrowAndShrink 时才会出现这种情况!?
这是某种错误还是我误解了该属性?
要重现此问题,您应该
- 启动一个新的 WinForms 项目
- 将 StatusStrip 添加到表单底部
- 运行项目(在我的情况下为调试/任何 CPU)
- 将表单拖动到主监视器左侧的辅助监视器
PS:似乎当我删除 StatusStrip 时,我根本无法调整表单大小,所以我猜测这是 StatusStrip 对象中的一些副作用/错误...
添加一个带有以下代码的复选框可以很清楚地表明该问题围绕 AutoSizeMode 属性
private void chkAutoGrowAndShrink_CheckedChanged(object sender, EventArgs e)
{
this.AutoSizeMode = chkAutoGrowAndShrink.Checked ?
AutoSizeMode.GrowAndShrink :
System.Windows.Forms.AutoSizeMode.GrowOnly;
}
更新:
由于我最近更换了机器,所以我现在使用 VS2010 并按住并按住这台新笔记本电脑重新进行了测试。看哪,问题不再是了。我仍然不确定这是从哪里来的,也许随着时间的推移它在.NET中得到了修复,也许这是一个驱动程序问题......我想我们现在永远不会,但似乎把这个问题留在这里没什么用,所以我将其标记为关闭。 感谢所有投入宝贵时间的人!
I'm having the weirdest problem here with a Windows App written in c#.
Although there is absolutely nothing special about it, the main window works perfectly well on the Primary monitor and on any Secondary monitor when the latter is configured to stand on the right of the Primary monitor. However, when I reconfigure the secondary screen to be placed on the left side of my Primary monitor, I (and others) no longer can change the size of the form. The mouse-pointer does NOT change into the 'NW-SE-arrows', nor does clicking & dragging the edge react in any change towards the size of the window.
Doing some extra experimenting this seems to surface only when I have the AutoSizeMode of the form set to GrowAndShrink !?
Is this some kind of bug or am I misinterpreting the property ?
To reproduce this problem you should
- start a new WinForms project
- Add a StatusStrip to the bottom of the form
- Run the project (Debug/Any CPU in my case)
- Drag the form to the secondary monitor that stands LEFT of your primary monitor
PS: it seems that when I remove the StatusStrip, I can't resize the form at all, so I'm guessing this is some side-effect/bug in the StatusStrip object...
Adding a checkbox with the following code behind makes it pretty clear that the issue revolves around the AutoSizeMode property
private void chkAutoGrowAndShrink_CheckedChanged(object sender, EventArgs e)
{
this.AutoSizeMode = chkAutoGrowAndShrink.Checked ?
AutoSizeMode.GrowAndShrink :
System.Windows.Forms.AutoSizeMode.GrowOnly;
}
UPDATE:
As I've recently switched machines I've now redone the test on this new laptop using VS2010 and hold & behold, the issue is no longer. I'm still not sure where this came from, maybe it got fixed in .NET over time, maybe it was a driver issue... I guess we'll never now but it seems there is little use to keep this question here so I'll just mark it for closing. Thanks to all who put some of their precious time in it though!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您无法使用不在表单上的 StatusStrip 来调整大小,那么这里会出现另一个问题。所有表单都应可调整大小,除非您设置 FormBorderStyle 属性设置为固定样式。
If you can't resize with the StatusStrip not on the form, then there is another issue going on here. All forms should be resizable unless you set the FormBorderStyle property to a Fixed style.
似乎这个问题是硬件/驱动程序/特定版本的.NET/???有关的。这样的结束问题。
Seems this issue was hardware/driver/specific version of .NET/??? related. Closing question as such.