当我们最大化窗体时如何在Windows窗体中放入控件 [英] how to fit controls in windows form when we maximize the form

查看:89
本文介绍了当我们最大化窗体时如何在Windows窗体中放入控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

我在vs 2010中有一个Windows窗体.我希望当我最大化窗体时,该窗体中的控件也将最大化并自动调整该窗体.

hi friends

i have one windows form in vs 2010. i want when i maximize the form my controls in that form will also maximize & automatically adjust in the form.

推荐答案

它"这不是一个好主意.问题是,尽管很容易使控件随窗体自动增长和收缩-这只是设置Dock和Anchor属性或使用调整大小面板的一种情况-控件是唯一会增长或收缩的情况.缩小.例如,任何文本都不会,因此您最终得到一个巨大的按钮,中间有一个很小的小文本,看上去真的很傻.设计尺寸,并允许控件移动,但不要自动调整它们的大小.

您可以在WPF中很容易地做到这一点,但是其中涉及到严重的学习过程.
It''s not a good idea. The problem is that although it is easy to get controls to grow and shrink automatically with the form - it''s just a case of setting the Dock and Anchor properties, or of using resizing panels - the control is the only thing that grows or shrinks. Any text for example does not, so you end up with a massive button with teeny tiny text in the middle, looking really silly. Design for a size, and allow your controls to move, but don''t automatically re-size them all.

You can do it very easily in WPF, but there is a serious learning curve involved there.


使用 Anchor 属性定义如何将控件自动调整为调整其父控件的大小.

锚定到其父控件可确保在调整父控件的大小时,锚定的边缘相对于父控件的边缘保持在同一位置.

C#中的锚点属性 [有关以下内容的CP文章:使用锚固和对接属性 [ ^ ]

参考:锚定和对接 [
Use the Anchor property to define how a control is automatically resized as its parent control is resized.

Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.

Anchor Property in C#[^]
A CP article on: Working with Anchoring and Docking Properties[^]

Ref: Anchoring and Docking [^]



参见

MP3重新排列

看一下类FormPreview,方法OnResize()

您将必须调整数学以适合您的控件.

另外,看看我如何保持表单的大小,状态和位置.
Hi
see

MP3 Rearrange

look at class FormPreview, method OnResize()

You will have to adapt the math to fit your controls.

Also, look at how I persist the form size, state and location.


这篇关于当我们最大化窗体时如何在Windows窗体中放入控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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