Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiform application without MDI using Panels 1

Status
Not open for further replies.

davisg

IS-IT--Management
Sep 21, 2002
35
GB
I want to write a multiform application but I don't want to use MDI. I have seen this done in other languages, i.e. Delphi. Is there a way you can open a form from within a form and view it in a control such as a panel?

e.g.

Dim frm as new myform()
frm.parent = Me.Panel1
frm.Show()

The above gives me an exception of: Cannot add a top level control to a control.



Geoff.
 
Any takers on this one? I'm sure it can be done !

Geoff.

Geoff.
 
Set the 'child' form's TopLevel property to False and it will work:

Dim f as New Form2

f.TopLevel = False

Panel1.Controls.Add(f)

f.Show
 
SHelton,

Many thanks, that worked a treat.


Geoff.
 
Something along the lines of the following should work:
Code:
For Each ct As Control In Panel1.Controls

    If TypeOf ct Is Form2 Then Exit Sub

Next

'No Form2 in panel, create it...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top