如何调整(最大化)Windows窗体中的所有控件一次性 [英] How to Resize(Maximize) All the controls in Windows Forms All at Once

查看:73
本文介绍了如何调整(最大化)Windows窗体中的所有控件一次性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个C#Windows应用程序,项目已经完成。

当我最大化窗口时,右侧空间就会创建。



i希望我的所有控件大小都随着窗口最大化/最小化而增加/减少。

请帮助

I have Implemented One C# Windows Application and the Project is Almost completed.
When i maximized window then on right side space is create .

i want my all control size is increase/decrease as window is maximized/minimized.
please help

推荐答案

Windows Forms永远不会在re-size模型上提供了一个非常强大的重新定位/重新定位;但是,在大多数应用程序中,您可以在ContainerControls(Panel,GroupBox,FlowLayoutTable等)上使用Dock,Padding和Margin属性(如Sergey建议的那样)以及它们内部控件上的Margin和Anchor属性来获得良好的结果。



另一种选择是使用第3名。派对接/平铺库像Weifen Luo的开源(免费)DockPanelSuite [ ^ ]。



就你当前问题的实际解决方案而言,我建议你按照蒂姆的建议,然后测试看看有什么不是在视觉上看起来正确,并尝试在所涉及的ContainerControls上使用Dock。



最糟糕的情况是你必须在Form / ContainerControl重新调整大小事件中编写一些代码。
Windows Forms has never provided a really powerful re-locate/re-size on re-size model; but, in most applications you can achieve good results with using Dock, Padding, and Margin Properties (as Sergey suggests) on the ContainerControls (Panel, GroupBox, FlowLayoutTable, etc.), and the Margin and Anchor Properties on the Controls inside them.

Another alternative is to use a 3rd. party docking/tiling library like Weifen Luo's open-source (free) DockPanelSuite [^].

In terms of a practical solution to your immediate problem, I suggest you follow Tim's suggestion, then test and see what doesn't look right visually, and try using Dock on the involved ContainerControls.

Worst case is you have to write some code in the Form/ContainerControl re-size Events.


以这种方式设计它不是一个好主意。相反,您应该更好地定义在调整窗口大小时重新排列的布局。请查看我过去的答案:

屏幕分辨率更改时,Zom Out出现故障 [ ^ ](这里是一个简单的代码示例),

如何停靠按钮,以便它可以调整窗体 [ ^ ]。



另见这一篇: GUI外观 - C#.Net [ ^ ]。



首选使用 Control 属性 Dock 填充超过锚点(仍然涉及手动调整大小并在某些控件中导致闪烁)。



-SA
It's not a good idea to design it this way. Instead, you should better define the layout which is rearranged nicely as you resize the window. Please see my past answers:
Zom Out malfunctions when Screen resolution changes[^] (a simple code sample here),
how to dock button so that it can adjust with the form[^].

See also this one: GUI Apperance - C#.Net[^].

Prefer using the Control properties Dock and Padding over Anchor (which still involves manual resize and causes flicker in some controls).

—SA


您可以将所有控件锚定在左侧,右侧,顶部和底部。
You could anchor all of your controls to the left, right, top and bottom.


这篇关于如何调整(最大化)Windows窗体中的所有控件一次性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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