I have a form containing a flowlayoutpanel, and a user control A is added to the panel. In the constructor of user control A, a pointer to the same flowlayoutpanel is passed, so that user control A creates another user control B in the same flowlayoutpanel. The problem is that user control B is first added, then A.
Form1.cs
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void addBtn_Click(object sender, EventArgs e)
{
flowLayoutPanel1.Controls.Add(new Graphic1(this.flowLayoutPanel1));
}
}
Graphic1.cs
public partial class Graphic1 : UserControl
{
public Graphic1(FlowLayoutPanel flowPointer)
{
InitializeComponent();
flowPointer.Controls.Add(new Graphic2());
}
}
Graphic2.cs is just a label
problem is that Graphic2.cs is added before Graphic1.cs in the panel