无法在FlowLayoutPanel控件中调整子控件的大小 [英] Cannnot resize Child Controls in a FlowLayoutPanel Control

查看:388
本文介绍了无法在FlowLayoutPanel控件中调整子控件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明 我试图创建一个可以扩展的FlowLayoutPanel,例如以水平方式.

Description I was trying to create a FlowLayoutPanel that can be extended, for instance in the horizontal way.

FlowLayoutPanel及其子组件锚点已设置为Top-Left-Right

FlowLayoutPanel and its sub component anchor has been set to Top-Left-Right

FlowLayoutPanel方向已设置为TopDown.

FlowLayoutPanel direction has been set to TopDown.

->调整FlowLayoutPanel的大小时,其子组件的大小不会相应调整.

-> When rezising the FlowLayoutPanel, its sub- components are not resized accordinally.

复制步骤

  1. 在表单上创建FlowLayoutPanel控件.

  1. Create a FlowLayoutPanel control on your form.

将FlowLayoutPanel的FlowDirection设置为TopDown.

Set the FlowDirection of the FlowLayoutPanel to TopDown.

创建一个Button控件,并将其放置在FlowLayoutPanel控件中.

Create a Button controls, and place it in the FlowLayoutPanel control.

选择按钮和FlowLayoutPanel并将其锚点设置为左上右

Select the Button and the FlowLayoutPanel and set their Anchor to Top-Left-Right

尝试水平扩展FlowLayoutPanel.

Try to Extend FlowLayoutPanel on the horizontal way.

->调整FlowLayoutPanel的大小,但不调整按钮

-> FlowLayoutPanel is resized but not the Button

推荐答案

FlowLayoutPanel仅用于以动态方式对其子控件进行布局.这并不意味着它们会在FlowLayoutPanel中自动调整大小.我猜想FlowLayoutPanel会忽略其子控件的Anchor属性.

The FlowLayoutPanel is only meant to layout it's child controls in a dynamic way. This does not mean that they will automatically resize within the FlowLayoutPanel. I'm guessing that the FlowLayoutPanel ignores the Anchor properties of it's child controls.

要实现此效果,您需要在FlowLayoutPanel的SizeChanged事件上手动调整子控件的大小.

To achieve this effect you'll need to manually resize your child controls on the FlowLayoutPanel's SizeChanged event.

但是,在这一点上,您可能需要重新考虑FlowLayoutPanel是否确实是您要使用的对象.如果您一直希望按钮填充FlowLayoutPanel的宽度,则不妨将其粘贴在Panel中并使用锚点,或者将其设置为Dock属性.

At this point though, you may want to reconsider whether the FlowLayoutPanel is really what you want to be using. If you know that you always want a button to fill the width of the FlowLayoutPanel, you might as well stick it in a Panel and use the anchors, or set it's Dock property.

这篇关于无法在FlowLayoutPanel控件中调整子控件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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