2016-11-14 9 views
0

私はこのflowLayoutPanelを、配列の内側のコントロールがウェルの最後のものがパネルの下の境界に達するまで設定した後、コントロールが垂直方向のフローをキープする右側に配置を開始します。私はちょうど1列がほしい。代わりになぜflowlayoutPanelが水平方向に伸びていますか?

this.panel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;

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; 
+0

ことができるからです。その仕事は、スペースを無駄にせず、スクロールバーを表示しないことです。幅を小さくすることを検討してください。 –

答えて

2

使用

this.panel.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;

あなたはコントロールがあなたのflowlayoutpanelに追加した直後に、アプリケーションにコードの下に追加してくださいよりも、1つの列のみをしたい場合

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); 
関連する問題