C# 如何首先在flowLayoutPanel1上添加标签?

C# 如何首先在flowLayoutPanel1上添加标签?,c#,winforms,C#,Winforms,如何首先在flowLayoutPanel1上添加标签? 我想把标签控件放在第一个或第二个索引中如何? 那是只读的吗 Label lb = new Label(); lb.AutoSize = true; lb.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(187)))), ((int)(((byte)(206)))), ((int)(((byte)(241))))); lb.Location = new System.Drawi

如何首先在flowLayoutPanel1上添加标签? 我想把标签控件放在第一个或第二个索引中如何? 那是只读的吗

Label lb = new Label();
lb.AutoSize = true;
lb.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(187)))), ((int)(((byte)(206)))), ((int)(((byte)(241)))));
lb.Location = new System.Drawing.Point(122, 3);
lb.Margin = new System.Windows.Forms.Padding(0, 3, 3, 0);
lb.Name = "label2";
lb.Size = new System.Drawing.Size(45, 13);
lb.TabIndex = 13;
lb.Text = "XXX";
flowLayoutPanel1.Controls[0] = lb?
用于将标签添加到
flowLayoutPanel1
,然后用于将控件的索引设置为所需的任何值:

flowLayoutPanel1.Controls.Add(lb);              // Adds lb to flowLayoutPanel1
flowLayoutPanel1.Controls.SetChildIndex(lb, 0); // Sets index of lb to 0

是的,那是我的错误。现在修好了。