tags:

views:

37

answers:

1

how to add label on flowLayoutPanel1 at first index0? i would like to put label control in first or secound index how? that readonly?

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?
+2  A: 

Use Controls.Add to add the label to flowLayoutPanel1, and then use SetChildIndex to set the index of the control to whatever you want:

flowLayoutPanel1.Controls.Add(lb);              // Adds lb to flowLayoutPanel1
flowLayoutPanel1.Controls.SetChildIndex(lb, 0); // Sets index of lb to 0
Donut
Controls.SetChildIndex?
monkey_boys
Yep, that was my mistake. Fixed now.
Donut