C#Winforms调整大小问题 [英] C# Winforms resize problem
本文介绍了C#Winforms调整大小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨大家好
我一直在尝试以编程方式重新调整ac#winforms格式。
我用这个来实现这个目的:
this.Size = new Size(900,900);
但是当窗口最大化时,这不起作用。
任何想法如何让表格在最大化状态下重新调整尺寸? />
提前致谢,
Baxter。
Hi Guys
I have been trying to programmatically re-size a c# winforms form.
I have achieved this using:
this.Size = new Size(900, 900);
But this does not work when the window is maximized.
Any ideas how I can get the form to re-size when it's in the maximized state ??
Thanks in advance,
Baxter.
推荐答案
如果你想重新 - 在保持最大化状态的同时大小窗口,然后你做错了。
但是我假设你想从最大化状态重新调整它的大小。在这种情况下,你只需按照joshduncan2012的建议做,并将windowstate改回正常状态。
If you want to re-size the window while keeping the maximized state, then you're doing it wrong.
But I'm assuming rather that you want to re-size it from a maximized state. In this case, you just have to do as joshduncan2012 suggested, and change the windowstate back to normal.
this.WindowState = FormWindowState.Normal;
this.Size = new Size(yourWidth,yourHeight);
一旦this
引用您的表单,它就应该工作,并且它没有最大化或最小化。另一种选择是设置表单属性的值Width
和Heigh
。
-SA
It should work as soon as "this
" references your form and it is not maximized or minimized. Another option is to set the values of the form's propertiesWidth
andHeigh
.
—SA
嗨大家好,
感谢您的帮助。
这是我在你的帮助下找到的工作解决方案:
Hi Guys,
Thanks for the help.
Here is the working solution I have found with your help:
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Minimized;
this.WindowState = FormWindowState.Normal;
this.BringToFront();
}
else
{
Int32 width = this.Width;
Int32 height = this.Height;
this.Size = new System.Drawing.Size(902, 907);
this.Size = new System.Drawing.Size(width, height);
}
非常感谢。
这篇关于C#Winforms调整大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文