开发者

References to open forms

开发者 https://www.devze.com 2023-02-05 11:17 出处:网络
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 fo

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(); 
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消