I'm working on C# .NET 3.5 desktop application. In the software I have a Form
, which contains a TableLayoutPanel
tp1
. The 2nd row of the tp1
contains a GroupBox
. The GroupBox
contains another TableLayoutPanel
tp2
. tp2
will grow dynamically during runtime.
Form
-----------------------------
| TableLayoutPanel tp1 |
|____________________________|
| GroupBox |
| ________________________|
| | |
| | TableLayoutPanel tp2 |
| | ______________________|
| | | |
| | | Dynamic content |
| | | here |
| | | |
| | |______________________|
| |________________________|
| |
|____________________________|
-----------------------------
The AutoScroll of the Form
is true.
The SizeType of Row 2 of tp1
is AutoSize.
The AutoSize of the GroupBox
is true.
The AutoSize of tp2
is true. tp2
is dynamically updated by the following code:
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);
I want a scrollbars to appear in the Form
when tp1
is larger than the window size. But no scrollbar is appearing.
I can activate scrollbars in the same way if I set AutoScroll to true for tp1
. But I want the scrollbars on the Form
, not tp1
.
How can I achieve that?