Form within a form

PlayKid

Freshman
Joined
Jun 25, 2005
Messages
38
Hi all,

I would like to know, how do I create a form within a form, say for example
I have created a main form, which contains all the controls, and also, some other forms that is within the application, all the maximization, minimization, resizing are all happened in the main form.

Thanks

PlayKid
 
set the main form to IsMDIContainer and you can define other forms as MDIChilds:

Main Form:
Visual Basic:
    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim frm1 As New Form1 
        frm1.MdiParent = Me
        frm1.Show()
    End Sub

And set IsMDIContainer = true
 
decrypt said:
set the main form to IsMDIContainer and you can define other forms as MDIChilds:

Main Form:
Visual Basic:
    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim frm1 As New Form1 
        frm1.MdiParent = Me
        frm1.Show()
    End Sub

And set IsMDIContainer = true


Hi, I have tried your method, but it seems not working, here is my code
Visual Basic:
    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim mainfrm As New MainForm
        mainfrm.MdiParent = Me
        mainfrm.Show()
    End Sub

The error is that the form cannot be both MdiChild and MdiParent, can you tell me how to solve it?
 
I had another problem, I got the main form to load a mdichild form fine, but when I am trying to load another from the mdichild form, it doesn't work.
Can you teach me now?
ie. I had a main form, I loaded a second form when I clicked a button from the main form, then I had another button on the second form, which load the third form, but can the third form do all the maximization and minimization within the main form?
Thanks
 
The new form must have the original parent form as its parent too, so in the second form you would have to use code like this:
Visual Basic:
Dim newForm As New Form3

newForm.MdiParent = Me.MdiParent
newForm.Show()
 
I have another method on this too....
the code that I got is
Visual Basic:
Dim newForm As New Form3
newForm.MdiParent = ParentForm
newForm.Show()
That also work.....but well, my version and yours are pretty similar....
 
PlayKid said:
I have another method on this too....
the code that I got is
Visual Basic:
Dim newForm As New Form3
newForm.MdiParent = ParentForm
newForm.Show()
That also work.....but well, my version and yours are pretty similar....
It works as long as you have declared a variable called ParentForm and assigned the parent form to it, but why do that when you already have the MdiParent property? The advantage might be that your variable would be of the correct specific type whereas MdiParent is of type Form, which would require a cast to use members of the derived class. If you don't use those members, however, it serves no purpose.
 
Nono.....the ParentForm is something from the VB.Net, I didnt declared anything as the Parent Form.
I found this thing out from VB.Net Help.
 
Back
Top