c# how would i Show() every form that i add?
i am creating instances of Form1() on the fly.
i need to be able to show it every time i open it. the result would be a bunch of popping up forms. here is my code. how do i show the form as soon as it is created>?
List<Form1> forms = new List<Form1>();
string analyte;
for(int i = 0; i < cbAnalytes.Items.Count; ++i)
{
cbAnalytes.SelectedIndex = i;
analyte = cbAnalytes.Text;
// Pro开发者_高级运维cess the object depending on the type
forms.Add(new Form1(dateStart.Value.ToShortDateString(), dateEnd.Value.ToShortDateString(), cbQCValues.Text, analyte, cbInstruments.Text));
}
You would have to specifically call each form's Show()
method.
Namely like so:
List<Form1> forms = new List<Form1>();
string analyte;
for(int i = 0; i < cbAnalytes.Items.Count; ++i)
{
cbAnalytes.SelectedIndex = i;
analyte = cbAnalytes.Text;
// Process the object depending on the type
Form1 aform = new Form1(dateStart.Value.ToShortDateString(), dateEnd.Value.ToShortDateString(), cbQCValues.Text, analyte, cbInstruments.Text);
aform.Show();
forms.Add(aform);
}
精彩评论