I need help docking in winforms, I googled everywhere and nothing works, somebody please tell me whats wrong, the panel and lable doesn't appear, Please do not judge im new to C#.
public void doDock()
{
string[] test = { "g", "x", "l" };
foreach(string p in test)
{
Panel pnl = new Panel();
pnl.Dock = DockStyle.Top;
this.dockpanel.Controls.Add(pnl);
//
Label namelabel = new Label();
namelabel.Location = pnl.Location;
namelabel.Text = p;
this.Controls.Add(pnl);
}
}
The definition of the panel should be once and outside (before) the loop.
I think you are looking for a FlowLayoutPanel which can support objects to be added one after one, confortably compared to a simple Panel (Location is automatic).
Then, think to investigate on your object properties - there are many - to let them appear as you wish. Among them: