gpt4 book ai didi

c# - flowlayout 控件不断在 winforms 中以错误的方向添加控件

转载 作者:可可西里 更新时间:2023-11-01 08:36:10 24 4
gpt4 key购买 nike

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

最佳答案

flowLayoutPanel1WrapContents属性设置为false,否则将不允许在右侧移动那些控件合身。为了能够滚动剪辑的内容,您可以将 AutoScroll 属性设置为 true

代码如下:

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

关于c# - flowlayout 控件不断在 winforms 中以错误的方向添加控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7741392/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com