开发者

Design apllication with muliple forms within one main form

I want to make an application that have one main form that have one functionality = Add new form.

I dont know how forms will be created, they are created dynamically by the user (AddForm methos from the main form).

All the subs forms are the same but some of thier prop receive 开发者_如何学Cdiffernce parameters (it can be in the ctor or later).

I want to be able to close all the forms when I close the main form.

Before new form will displayed I want to display setting form (to take the form parameters) maybe with ShowDialog method and do validating check on the form and just if the form validate the new form will displayed, if not (or if the user prees cancel) the form will disposed.

I know aboout MDI but I really perfer other way

Any ideas?

Thanks!


Closing all forms when main form is closed is somewhat easy, you just pass the main form reference in Show() method of the "child" forms; e.g. if you show child from main, you do:

child.Show(this);

This needs to be done if the your main form is not the real "main form of the program", but you want to close all "child" forms.

However, wiring all this together would preferably be done in some special class for this purpose, maybe called ScreenRepository. In this class, you would have a collection of open forms at any moment, you would deffer form creation to this class (so that this class automatically injects form parent) etc... Having this class would be easy to re-activate (give focus) the form if it is behind other forms, create new form if needed etc...


Idea is simple create a application that open a main form a the beginning and then open open other forms if needed if you close main form rest of forms are also closed. Like in GIMP.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜