1
我正在研究C#.NET 3.5桌面应用程序。在软件中,我有一个Form
,其中包含TableLayoutPanel
tp1
。 tp1
的第二行包含GroupBox
。 GroupBox
包含另一个TableLayoutPanel
tp2
。 tp2
将在运行时动态增长。动态内容的自动滚动Windows窗体
Form
-----------------------------
| TableLayoutPanel tp1 |
|____________________________|
| GroupBox |
| ________________________|
| | |
| | TableLayoutPanel tp2 |
| | ______________________|
| | | |
| | | Dynamic content |
| | | here |
| | | |
| | |______________________|
| |________________________|
| |
|____________________________|
-----------------------------
Form
的AutoScroll为true。
tp1
的第2行的SizeType是AutoSize。
GroupBox
的AutoSize为true。
自动尺寸为tp2
为真。 tp2
动态通过下面的代码更新:
tp2.RowCount = tp2.RowCount + 1;
tp2.RowStyles.Add(new RowStyle(SizeType.AutoSize));
GroupBox gb = new GroupBox();
gb.BackColor = Color.Red;
tp2.Controls.Add(gb, 0, tp2.RowCount - 1);
我希望有一个滚动条显示在Form
时tp1
比窗口大小。但没有滚动条出现。
我可以以相同的方式激活滚动条,如果我将AutoScroll设置为true tp1
。但我想要Form
上的滚动条,而不是tp1
。
我该如何做到这一点?
我得到了我的问题,这个答案之前解决办法。但感谢您的答案。 – Donotalo
太棒了!不客气,谢谢你的反馈:) –