我试图让一个WinForm(C#.NET)一个非常简单的自动调整大小的布局。我试过TableLayoutPanels和FlowLayoutPanels但没有任何工程。
I am trying to get a very simple autosizing layout on a winform (C# .NET). I've tried TableLayoutPanels and FlowLayoutPanels but nothing works.
我有一个用户控件是一个容器,它在运行时创建的其他用户控件 - 我把它称为StackPanel的,因为我希望它列出子控件垂直。我使用的是FlowLayoutPanel的,TableLayoutPanel中和面板(与停靠顶端每个控制)尝试这个。
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.
谢谢!
我已经与两个面板类似的经历。
I've had a similar experience with both Panels.
FlowLayoutPanel的:
FlowLayoutPanel:
您基本上都已经离开固定在左上角的子部件。不要停靠他们。也不要固定他们的权利。标签的自动调整大小将仅适用于该配置。
You basically have to leave your child widgets anchored to the top left. Don't dock them. Also don't anchor them to the right. Label auto-sizing will only work in this configuration.
然后就可以捕捉到FlowLayoutPanel中的resize事件并手动调整子组件的全部宽度。
Then you can capture the resize event of the FlowLayoutPanel and manually adjust all the widths of your child components.