Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

 

Main Form:

    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

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

 

Main Form:

    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

   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?

Posted

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

Posted
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:
Dim newForm As New Form3

newForm.MdiParent = Me.MdiParent
newForm.Show()

Posted

I have another method on this too....

the code that I got is

Dim newForm As New Form3
newForm.MdiParent = ParentForm
newForm.Show() 

That also work.....but well, my version and yours are pretty similar....

Posted
I have another method on this too....

the code that I got is

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.
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...