I'm working on a project for school but I'm stuck at this moment. I want to dynamically add comboboxes to my flowlayoutpanel which depends of the value of a numeric up and down.
So if the numeric up down value is 2 that 2 comboboxes are dynamically made, but I can't really figure how to do this, this is what I was thinking of.
public partial class ...Form: Form
{
ComboBox[] cbChoices;
private void nudGuests_ValueChanged(object sender, EventArgs e)
{
flowPanel.Controls.Clear();
for (int i = 1; i < nudGuests.Value; i++)
{
cbChoices[i] = new ComboBox();
flowPanel.Controls.Add(cbChoices[i]);
}
}
}
but I can't seem to get it to work.