C#: How to get a user control to properly auto size itself(C#:如何让用户控件正确地自动调整大小)
问题描述
我有一个 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#:如何让用户控件正确地自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C#:如何让用户控件正确地自动调整大小
基础教程推荐
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
