2011-10-12 33 views
11

Tôi có một điều khiển flowlayout trong winforms, tôi đã thiết lập hướng dòng chảy của nó để TopDown nhưng nó giữ thêm điều khiển từ trái sang phải, autoscroll cũng được đặt thành true.kiểm soát flowlayout giữ thêm kiểm soát theo hướng sai trong winforms

flowLayoutPanel1.Controls.Clear();  
Label labelInput = new Label(); 
ListBox listBoxNewInput = new ListBox(); 

//Initialize label's property 
labelInput.Text = " #" + Convert.ToInt32(sequence); 
labelInput.AutoSize = true; 

//Initialize textBoxes Property 
listBoxNewInput.HorizontalScrollbar = false; 

listBoxNewInput.Items.Add(efforts); 
//Add the newly created text box to the list of input text boxes 
inputTextBoxesList.Add(listBoxNewInput); 

//Add the labels and text box to the form 
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.Controls.Add(labelInput); 
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.Controls.Add(listBoxNewInput); 
+0

những gì tôi muốn là nếu họ không phù hợp theo chiều dọc nó nên thực hiện một thanh cuộn, nhưng nó đặt chúng ở bên phải – PUG

Trả lời

23

Đặt WrapContents tài sản của flowLayoutPanel1 để false, nó sẽ không cho phép di chuyển những người điều khiển ở bên phải nếu họ không phù hợp. Để có thể di chuyển nội dung cắt bớt bạn có thể đặt AutoScroll tài sản để true

Đây là mã:

flowLayoutPanel1.FlowDirection = FlowDirection.TopDown; 
flowLayoutPanel1.WrapContents = false; 
flowLayoutPanel1.AutoScroll = true; 
flowLayoutPanel1.Controls.Add(labelInput); 
flowLayoutPanel1.Controls.Add(listBoxNewInput); 
+1

OMG nó sẽ mất vài tuần để tôi giải quyết điều này mà không có ai đó trực tiếp nói. cổ vũ – ErTR

Các vấn đề liên quan