PUG*_*PUG 11 c# user-controls dynamic-controls flowlayoutpanel winforms
我在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);
Run Code Online (Sandbox Code Playgroud)
use*_*ame 24
设置to 的WrapContents属性,如果它们不适合,则不允许在右侧移动这些控件.为了能够滚动剪切的内容,您可以将属性设置为flowLayoutPanel1falseAutoScrolltrue
这是代码:
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
flowLayoutPanel1.WrapContents = false;
flowLayoutPanel1.AutoScroll = true;
flowLayoutPanel1.Controls.Add(labelInput);
flowLayoutPanel1.Controls.Add(listBoxNewInput);
Run Code Online (Sandbox Code Playgroud)