C# 如何保持最大化窗口不变?
我正在使用 Visual Studio 2010 来做我的 C# GUI。
我当前面临的问题是,最大化窗口后,它保持在那里,但当我转到其他窗体时,窗口将恢复到其原始大小。
单击最大化按钮后,如何为所有表单保留最大化窗口?
下面是一个示例:
- 用户最大化表单 A
- 表单 A 最大化
- 用户转到表单 B
- 表单 B 回到原始大小而不是最大化窗口
我想要的是,当用户最大化表单时,它会保持这种状态,直到程序关闭或调整大小。
I am using visual studio 2010 to do my C# GUI.
The current problem that I am facing is that after maximizing a window, it stays there but when I go to other forms, the window will go back to its original size.
How do I leave the maximized window all the way for all the forms, once I click the maximize button?
Heres an example:
- User maximizes Form A
- Form A maximized
- User goes to Form B
- Form B goes back to original size instead of a maximized window
What I want is when user maximizes a form, it stays that way till the program is closed or resized.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您使用的是 WinForms,您可以实现共享 FormWindowState 管理器或使用多文档界面 (MDI) 容器。
共享 FormWindowState
您可以向负责传播表单 FormWindowState 更改的类注册每个表单。
MDI 容器
MdiParentForm.cs
MdiChildForm.cs
您可以使用窗体的
MdiChildren
属性迭代窗体的 MDI 子级,这样当 MDI 子窗口更改其FormWindowState
时,MDI 父窗体可以将更改应用于其每个子级,类似于共享 FormWindowState 方法。这些想法只是我的想法,但也许它们会让你走向正确的方向。
Assuming you're using WinForms, you can have either implement a shared FormWindowState manager or use a Multiple Document Interface (MDI) container.
Shared FormWindowState
You can register each of your forms with a class responsible for propagating changes in forms' FormWindowState.
MDI Container
MdiParentForm.cs
MdiChildForm.cs
You can iterate through a form's MDI children using the form's
MdiChildren
property such that when on MDI child window changes itsFormWindowState
, the MDI parent form can apply the change to each of its children, similar to the shared FormWindowState approach.These ideas are just off the top of my head but maybe they'll get you in the right direction.