问题描述
我有一个 UserControl
,它由一个 Label
(顶部)、一个 FlowLayoutPanel
(填充、TopDown 流和不换行)和一个面板
(底部).用户控件根据获取的内容列表创建许多控件,并将它们添加到 FlowLayoutPanel
.
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
.
我怎样才能让这个 UserControl
正确调整自身大小,使 FlowLayoutPanel
没有任何滚动条?我尝试在 FlowLayoutPanel
和 UserControl
本身上使用 AutoSize
和 AutoSizeMode
的各种组合,但我可以似乎没有让它工作.要么我最终得到的东西根本不会自行调整大小,要么它没有变得足够大,要么它被压扁到几乎没有.
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.
推荐答案
感谢所有建议.这次的解决方案似乎将 FlowLayoutPanel
和 UserControl的
AutoSize
设置为 true
代码> 本身.
Thanks for all the suggestions. The solution this time seemed to set AutoSize
to true
for both the FlowLayoutPanel
and the UserControl
itself.
现在,如何获取将包含此 UserControl
以及其他一些控件的表单,目前我还不太清楚,但我想应该是一个单独的问题...
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#:如何让用户控件正确地自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!