我已经设置了这个flowLayoutPanel,里面的控件排列得很好,直到最后一次到达面板的底部边界,然后控件开始在右侧排列(形成另一列),保持垂直流。我只想要一个专栏。
this.panel.Anchor =
((System.Windows.Forms.AnchorStyles)
(((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)| System.Windows.Forms.AnchorStyles.Right)));
this.panel.AutoScroll = true;
this.panel.BorderStyle = BorderStyle.None;
this.panel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.panel.Location = new System.Drawing.Point(0, 184);
this.panel.Name = "myPanel";
this.panel.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.panel.Size = new System.Drawing.Size(300, 371);
this.panel.TabIndex = 9;发布于 2016-11-14 13:03:37
使用
this.panel.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
而不是
this.panel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
如果您只需要一个列而不是一个列,请在控件添加到流程布局面板后将下面的代码添加到您的应用程序中。
this.panel.SetFlowBreak(<<YOUR_ADDED_CONTROL_NAME>>, true);
示例
Button btn1 = new Button();
btn1.Text = "TEST";
btn1.Height = 30;
btn1.Width = 100;
this.panel.Controls.Add(btn1);
this.panel.SetFlowBreak(btn1, true);https://stackoverflow.com/questions/40589347
复制相似问题