locked
Problem whit addin controls in flowLayoutPanel RRS feed

  • Question

  • control1 ctr1 = new control1();  
                flowLayoutPanel1.Controls.Add(ctr1); 
     Hi,

    I have 3 controls I wish to add to a flowLayoutPanel . I have no problem adding them but Im having problems with contolling the order of which they open ,I want the controls to always be in following order (control1,control2,control3)

    Control 1 is always mounted but control 2 and 3 open upon request from user. Now for instance control 1 is open user opens control 2 and than 3 how do I make the controls maintain the same order (control1,control2,control3)¨ and not just add after each other depending on user request for ex. control 1,control3,control2 (is wrong)
    Any ideas of what I can do? all and any help appreciated .


    Wednesday, October 29, 2008 6:32 PM

Answers

  •  flowLayoutPanel1.Controls.SetChildIndex(control1, 0);
     flowLayoutPanel1.Controls.SetChildIndex(control2, 1);
     flowLayoutPanel1.Controls.SetChildIndex(control3, 2);
    • Proposed as answer by Harry Zhu Monday, November 3, 2008 1:33 AM
    • Marked as answer by Harry Zhu Monday, November 3, 2008 10:29 AM
    Thursday, October 30, 2008 4:03 PM

All replies

  • Use flowLayoutPanel1.Controls.SetChildIndex to move them around to the places you need.
    Wednesday, October 29, 2008 7:15 PM
  • Hi, Tan Silliksaar

    thx for reply  can you write small sample for me.
    Wednesday, October 29, 2008 7:36 PM
  •  flowLayoutPanel1.Controls.SetChildIndex(control1, 0);
     flowLayoutPanel1.Controls.SetChildIndex(control2, 1);
     flowLayoutPanel1.Controls.SetChildIndex(control3, 2);
    • Proposed as answer by Harry Zhu Monday, November 3, 2008 1:33 AM
    • Marked as answer by Harry Zhu Monday, November 3, 2008 10:29 AM
    Thursday, October 30, 2008 4:03 PM