如何调整(最大化)Windows窗体中的所有控件一次性

编程入门 行业动态 更新时间:2024-10-25 02:24:40
本文介绍了如何调整(最大化)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窗体中的所有控件一次性

本文发布于:2023-11-09 10:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572104.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   控件   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!