i am creating a programme where the user enters some data in to the opening form. based on that another window will open. In total i have 4 guis which work on a cyclical basis. You can get from one form to any of the others after a series of different clicks.
Without having to reload some of the forms from scratch (as开发者_高级运维 some have many queries that need to be run) and without having to form1,form2,form3.hide(), form4.show()
how can i do it "properly" :D
Thanks
You can use UserControls on one form, instead of working with many forms. Active control could be easily switched by calling userControl1.BringToFront() method.
If you always show them in the same order, you can use the Wizard approach, it's also useful if in the future you will add new forms in the middle or in the "edges", usually a wizard application holds somewhere a structure with all relevant data shared from all forms. Hope this helps.
No really. Why not:
private static Form[] _forms = new Form[] { form1, form2, form3, form4 };
public static void ShowForm(Form form) {
foreach (Form f in _forms) {
if (f == form)
f.Show();
else
f.Hide();
}
}
精彩评论