我在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);发布于 2011-10-12 22:28:24
将flowLayoutPanel1的WrapContents属性设置为false,如果不适合,它将不允许移动右侧的控件。为了能够滚动剪切的内容,可以将AutoScroll属性设置为true
代码如下:
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
flowLayoutPanel1.WrapContents = false;
flowLayoutPanel1.AutoScroll = true;
flowLayoutPanel1.Controls.Add(labelInput);
flowLayoutPanel1.Controls.Add(listBoxNewInput);https://stackoverflow.com/questions/7741392
复制相似问题