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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I have a form inside a form?

Status
Not open for further replies.

LonnieJohnson

Programmer
Apr 16, 2001
2,628
US
In MS Access there is what is called a sub form. Does such a concept exist in winforms? More specifically in WPF, I would like to have a main form (sort of like a master page in asp.dot). Then I would have a menu in the main or master form that calls, loads or alternates sub forms or child forms into the main form.

I am sure it can be done because there seems to be no limit to what you can do with vb.net.

Thanks in advance.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
If I got your question correctly, the [blue]Controls.Add[/blue] will do.
 
Thank you so much. Do you have any sample code? Would I add a new window to the current window?

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
No clue about WPF, but this is how you do it in WinForms:

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim f2 As New Form2
        f2.TopLevel = False
        Me.Controls.Add(f2)
        f2.Show()
    End Sub
 
Thanks RiverGuy,

I actually saw this code in another post you had submitted. I tried it but it did not quite work for the WPF objects. I will keep trying to tweek it.

Thanks again.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Using RiverGuy's code I get a couple of errors.

The first was on the f2.TopLevel = False line. I had to replace it with f2.Topmost = False. But I cannot run it still because it does not like the Me.Controls.Add(f2). It is saying that controls is not a member of the class.

For WPF what is the equivilent for a window or page vs the Controls in a form?

Thanks.

ProDev, Builders of Affordable Software Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top