Board index » Visual Studio » Parent and child forms

Parent and child forms

Visual Studio184
Hi!!

I created a form that I already set as IsMdiContainer to True.

How can I tell each new form I create to work under the container form

without having to declare the

aboutfsm.MdiParent = Me

login.MdiParent = Me

NEWPILOT.MdiParent = Me

to every single form I create.

Any suggestions?



Also, how can I tell my form to use the available space inside the container

form when opening?

I tried Maximized when setting the default form load but doesn't work.



Thanks much in advance.



Teo


-
 

Re:Parent and child forms

"Teo" <nospamteo@homsany.net>schrieb:

Quote
I created a form that I already set as IsMdiContainer to True.

How can I tell each new form I create to work under the container form

without having to declare the

aboutfsm.MdiParent = Me

login.MdiParent = Me

NEWPILOT.MdiParent = Me

to every single form I create.

Any suggestions?



How many different form types do you have?! You could save some lines of

code by writing a procecure:



\\\

Public Sub ShowFormInContainer( _

ByVal ChildForm As Form _

)

ChildForm.MdiParent = Me

End Sub

...

ShowFormInContainer(New AboutForm())

ShowFormInContainer(New LoginForm())

...

///



Quote
Also, how can I tell my form to use the available space inside the

container form when opening?

I tried Maximized when setting the default form load but doesn't work.



Did you try to maximize the forms in the child forms' 'Load' event handlers

or in the 'Load' event handler of the MDI container?



If your child forms are always maximized, you may want get back to a normal

form as the main form which contains a tabcontrol whose pages host user

controls. Each child form can then be replaced by a user control.



--

M S Herfried K. Wagner

M V P <URL:dotnet.mvps.org/>">dotnet.mvps.org/>

V B <URL:dotnet.mvps.org/dotnet/faqs/>">dotnet.mvps.org/dotnet/faqs/>



-