C#:如何让用户控制自动调整大小 [英] C#: How to get a user control to properly auto size itself

查看:137
本文介绍了C#:如何让用户控制自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UserControl ,它包含一个标签(Top),一个 FlowLayoutPanel (Fill,TopDown流程和无换行)和面板(Bottom)。用户控件根据所获得的东西列表创建一些控件,并将它们添加到 FlowLayoutPanel 中。



如何获得这个 UserControl 正确调整大小,以便 FlowLayoutPanel 没有任何滚动条?我试图使用 AutoSize AutoSizeMode FlowLayoutPanel UserControl 本身,但我似乎无法使其工作。或者我最终都没有调整自己的大小,或者它不会变得足够大,或者被压缩到几乎没有。

解决方案感谢所有的建议。此次的解决方案似乎将 AutoSize 设置为 true FlowLayoutPanel UserControl 本身。



现在,如何获取包含这个 UserControl 以及其他一些控件的表单,我现在不能弄清楚,但我猜应该是一个单独的问题。 ..


I have a UserControl which consists of a Label (Top), a FlowLayoutPanel (Fill, TopDown flow and no wrap) and a Panel (Bottom). The user control creates a number of controls, based on a list of stuff it gets, and adds them to the FlowLayoutPanel.

How can I get this UserControl to properly resize itself so that the FlowLayoutPanel does not have any scroll bars? I have tried to use various combinations of AutoSize and AutoSizeMode on the FlowLayoutPanel and the UserControl itself, but I can't seem to get it working. Either I end up with something that doesn't resize itself at all, or it doesn't become big enough or it is squished down to almost nothing.

解决方案

Thanks for all the suggestions. The solution this time seemed to set AutoSize to true for both the FlowLayoutPanel and the UserControl itself.

Now, how to get the form which will contain this UserControl as well as some other controls, that I can't quite figure out at the moment, but I guess that should be a separate question...

这篇关于C#:如何让用户控制自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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