Re: MDIForm Parent/Child forms BEST Practice
From: Armin Zingler (az.nospam_at_freenet.de)
Date: 04/22/04
- Next message: Sajid: "Simple question about datagrid row"
- Previous message: Armin Zingler: "Re: "Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your project.""
- In reply to: Edwinah63: "MDIForm Parent/Child forms BEST Practice"
- Next in thread: EricJ: "Re: MDIForm Parent/Child forms BEST Practice"
- Reply: EricJ: "Re: MDIForm Parent/Child forms BEST Practice"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 22 Apr 2004 10:30:51 +0200
"Edwinah63" <edwinah@customercare.com.au> schrieb
> Hi everyone,
>
> could someone give me some thoughts on the best way to manage mdi
> parent and child forms?
>
> in vb6 i could scroll through the forms collection and determine
> which forms were open/closed and their current state. now i
> can't.
You have the MdiChildren property in the MDI form.
> before i didn't have to declare numerous named instances each time
> i loaded or unloaded a form.
If you don't need to handle them specifically, an array, or Arraylist or
whatever would be sufficient. Or the mentioned Mdichildren property.
> if i open a child form from another child form and try to assign
> mdimain as the mdiparent it doesn't permit it, if i say f1.mdiparent
> = me.mdiparent i get memory problems (as have others judging from
> the groups).
>
> all my current forms are declared public shared in mdiMain, but
> should these be in a user made forms collection owned by a global
> module (cMain)?
I'd keep them in the MDI parent. I'd not even declare them public, but
instead pass references if needed.
> if i am finished with a child form, i want to unload it, not hide
> it, but if i close a form in vb.net it extinguishes the instance.
>
> when the mdi parent closes, i would like the app to terminate.
>
> should i be setting mdi children to nothing or disposing them?
No, not necessary. The children are closed before the parent is closed, and
closed forms are also disposed automatically.
> basically, what can/should i do to get the same mdi parent/child
> management present in vb6 while still preserving the smallest
> footprint possible in memory?
>
> all comments/code greatly appreciated. i am probably not the only
> programmer to ponder this question.
I'm not sure what's exactly your problem. I don't have memory problems. If I
wanted to create and later access an object (like a Form), I'd declare a
variable to store the reference. You can create one variable per Form
(advantage: don't have to search for it in a collection) or store them all
in a collection (advantage: no single variables needed), or both. Or use a
Hashtable to store them. If there can be only one instance of each Form
class, you could use the class name as the key (form.gettype.fullname).
-- Armin How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
- Next message: Sajid: "Simple question about datagrid row"
- Previous message: Armin Zingler: "Re: "Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your project.""
- In reply to: Edwinah63: "MDIForm Parent/Child forms BEST Practice"
- Next in thread: EricJ: "Re: MDIForm Parent/Child forms BEST Practice"
- Reply: EricJ: "Re: MDIForm Parent/Child forms BEST Practice"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|