flowlayout控件在winforms中继续向错误的方向添加控件

时间:2011-10-12 14:07:56

标签: c# winforms user-controls dynamic-controls flowlayoutpanel

我在winforms中有一个flowlayout控件,我已将其流向设置为TopDown但是它从左到右依次添加控件,autoscroll也设置为true。

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);

1 个答案:

答案 0 :(得分:24)

WrapContents的{​​{1}}属性设置为flowLayoutPanel1,如果它们不合适,则不允许在右侧移动这些控件。为了能够滚动剪辑的内容,您可以将false属性设置为AutoScroll

以下是代码:

true