4

I am trying to get a very simple autosizing layout on a winform (C# .NET). I've tried TableLayoutPanels and FlowLayoutPanels but nothing works.

I have a usercontrol which is a container for other usercontrols which are created at runtime - I've called it StackPanel as I want it to list the child controls vertically. I've tried this using a FlowLayoutPanel, TableLayoutPanel and a Panel (with each control docked to the top).

The child usercontrol consists of a label and then any number of radiobuttons (or any other standard control - it doesn't matter).

When the child controls are created, the label text is set (if this is long it needs to wrap to a new line) and the radio buttons are added.

There seems to be no combination of docking/autosizing or manual size setting using the Resize events that can get everything to show without clipping and still resize with the form.

Thanks!

4

1 回答 1

2

我对这两个小组都有类似的经历。

流布局面板:

您基本上必须将您的子小部件固定在左上角。不要停靠它们。也不要将它们锚定在右侧。标签自动调整大小仅在此配置中有效。

然后您可以捕获 FlowLayoutPanel 的 resize 事件并手动调整子组件的所有宽度。

于 2010-05-07T13:07:19.880 回答