C# 如何正确对齐FlowLayoutPanel中的控件

C# 如何正确对齐FlowLayoutPanel中的控件,c#,winforms,layout,flowlayoutpanel,C#,Winforms,Layout,Flowlayoutpanel,我目前正在尝试与c。我想创建一个简单的GUI,其中至少包含三个标签。前两个按钮应该从上到下对齐,第三个按钮应该在这两个按钮的右侧对齐 我把它放在一个面板里,就像 Label p_LabelX = new Label(); p_LabelX.Text = "I am to the right"; FlowLayoutPanel p_ButtonLayout = new FlowLayoutPanel(); p_ButtonLayout.Width = 200; Label p_Label1 =

我目前正在尝试与c。我想创建一个简单的GUI,其中至少包含三个标签。前两个按钮应该从上到下对齐,第三个按钮应该在这两个按钮的右侧对齐

我把它放在一个面板里,就像

Label p_LabelX = new Label();
p_LabelX.Text = "I am to the right";

FlowLayoutPanel p_ButtonLayout = new FlowLayoutPanel();
p_ButtonLayout.Width = 200;
Label p_Label1 = new Label();
p_Label1.Text = "I am upper left";

Label p_Label2 = new Label();
p_Label2.Text = "I am lower left";

p_ButtonLayout.Controls.Add(p_Label1);
p_ButtonLayout.Controls.Add(p_Label2);

FlowLayoutPanel p_MainLayout = new FlowLayoutPanel();
p_MainLayout.FlowDirection = FlowDirection.LeftToRight;
p_MainLayout.WrapContents = false;
p_MainLayout.AutoScroll = true;
p_MainLayout.Controls.Add(p_ButtonLayout);
p_MainLayout.Controls.Add(p_LabelX);

this.Controls.Add(p_MainLayout);
有了这段代码,它就可以工作了,但是我有一些滚动条,并且面板中的主布局不是全屏的。但是,如果我跳过AutoScroll行,滚动条将消失,布局似乎是全屏的,但右侧按钮不可见


有什么建议吗?

这似乎是System.Windows.Forms。如果您刚刚开始使用C,那么最好从当前的UI实现WPF开始。表单既旧又笨重。正确,但我在Linux中使用mono,因此afaik WPF不是让flowlayout全屏显示的选项尝试flowlayout的Dock属性并将其设置为Fill。我试过了,它在这里奏效了。也许您应该给flowlayouts一个Borderstyle,以查看它们的位置=>FlowLayout.Borderstyle=Borderstyle.FixedSingle进行测试编辑:仅dock p_mainLayout进行填充。另一个选项可以是TableLayoutPanel。快乐的学习测试;