Re: MDIForm Parent/Child forms BEST Practice
From: EricJ (ericReMoVe_at_ThiSbitconsult.be.RE)
Date: 04/22/04
- Next message: Armin Zingler: "Re: "Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your project.""
- Previous message: Sarah Smith: "speeding up form display/repaints in MDI apps"
- In reply to: Edwinah63: "MDIForm Parent/Child forms BEST Practice"
- Next in thread: Armin Zingler: "Re: MDIForm Parent/Child forms BEST Practice"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 22 Apr 2004 10:28:05 +0200
I don't know if w i do is the best way of doing things but it works. i'll
try to put it under your questions.
"Edwinah63" <edwinah@customercare.com.au> wrote in message
news:d714e824.0404211752.c0bb836@posting.google.com...
> Hi everyone,
>
> could someone give me some thoughts on the best way to manage mdi
> parent and child forms?
>
First i always create a public var of my main form (mdi parent) for easy
access (yust declare it in a module and i the parent.load set the var to me)
> in vb6 i could scroll through the forms collection and determine which
> forms were open/closed and their current state. now i can't.
>
something like this?
For Each f As Form In fmMain.MdiChildren
If f.Visible Then
End If
Next
> before i didn't have to declare numerous named instances each time i
> loaded or unloaded a form.
>
the named instance is declared locally so once you are out of this sub it is
gone
Dim manPSNT As New frmManPSNType
manPSNT.MdiParent = Me
manPSNT.Show()
> 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).
>
I use the public instance of my main form to do this. But i have don it w
the me.MdiParent should work. (unless you are doing strange things in the
client forms, try loading them non mdi first)
> 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)?
you that would be more organized but generally you don't need them all
> 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.
>
sounds right you will have to assign a new instance of the form to the var,
it all depends on w you want to do at that givven time.
> when the mdi parent closes, i would like the app to terminate.
>
try this
Private Sub frmMain_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Application.Exit()
End Sub
> should i be setting mdi children to nothing or disposing them?
>
.NET will do that for you
> 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?
if you want less mem don't declare all your forms as globals, .NET handles
it rather good the standard way.
>
> all comments/code greatly appreciated. i am probably not the only
> programmer to ponder this question.
>
> regards
>
> Edwinah63
There are probably bether ways to do some things, comments are welcome.
Hope it helps a bit
Eric
- Next message: Armin Zingler: "Re: "Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your project.""
- Previous message: Sarah Smith: "speeding up form display/repaints in MDI apps"
- In reply to: Edwinah63: "MDIForm Parent/Child forms BEST Practice"
- Next in thread: Armin Zingler: "Re: MDIForm Parent/Child forms BEST Practice"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|