I have a button which when pressed adds a UserControl into a panel. Essentially what i want is the next time you press it, it would add another exact same userControl but underneath the last one.
So far i have tried this:
int count = 0;
private void B_AddQuestion_Click(object sender, EventArgs e)
{
QuestionAdder QA = new QuestionAdder();
i++;
for (int j = 0; j < count; j++)
{
Panel.Controls.Add(QA);
GBX_Title.Text = i.ToString(); //This was to test to see if its counting
}
}
essentially this is working but what i think is happening is that it's adding user controls on top of each other. I tried changing the top and left but to no avail.
Maybe if I check if there is a user control, then add the next one below it?
EDIT: I did test flowLayoutPanels but I can't use this, since I would be having more userControls which must go NextTo the last userControl
EDIT: My Mistake, you can very well do this by using flowLayoutPanel, setting flowDirection to TopDown and disabeling wrap contents, thanks!
Panelinstead ofFlowLayoutPanel. To do so, setAutoScrollproperty of thePanelto true, then add user control instances to the panel and setDockproperty of them toTop. Take a look at this example. - Reza AghaeiFlowLayoutPanel? - Sipo