-2

i made 15 form in my project after that i made home form a parent MDI from by giving property isMDIparent true.now i want to make all form as child form of home form but i dont no way to do.so please suggest me code to assign all form to make child form of parentMDI home form.

user1945423
  • 71
  • 2
  • 2
  • 5

5 Answers5

1

You need to set the child Form's MdiParent Property to your MdiContainer. This example assumes two Forms one named Form1 and the other named Form2. All properties are being set programmatically.

Public Class Form1

    Public Sub New()

        InitializeComponent()
        Me.IsMdiContainer = True
        Dim frm2 As Form2 = New Form2
        frm2.Owner = Me
        frm2.MdiParent = Me
        frm2.Show()

    End Sub
End Class
Mark Hall
  • 53,938
  • 9
  • 94
  • 111
1

Here's the answer, straight from Microsoft:

Protected Sub MDIChildNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
   Dim NewMDIChild As New Form2()
   'Set the Parent Form of the Child window.
   NewMDIChild.MdiParent = Me
   'Display the new form.
   NewMDIChild.Show()
End Sub

http://msdn.microsoft.com/en-us/library/vstudio/7aw8zc76(v=vs.100).aspx

PDX Geek
  • 51
  • 4
0

I think Mr.Mark Hall missed 1 property.., Try this.......

Public Class Form1

Public Sub New()

    InitializeComponent()
    Me.IsMdiContainer = True
    Dim frm2 As Form2 = New Form2
    frm2.Owner = Me
    frm2.MdiParent = Me.MdiParent
    frm2.Show()

End Sub

End Class
bummi
  • 27,123
  • 14
  • 62
  • 101
0

it is actualy this:

Private sub new()

Dim c as form1 = new form1
c.owner = Me
c.MdiParent = Me
c.show

End sub

InitializeComponent() does just what it says, it initializes a component. It is NOT for Mdichild.

0
Private Sub HomeToolStripMenuItem_Click(sender As Object, e As EventArgs)
   Dim homechild As New login
   homechild.MdiParent = Me
   homechild.Dock = DockStyle.Fill
   homechild.Show()
End Sub

Try This Guys..Here Is the Code To Open A Form As MDI Child for an MDI Parent From in vb.net.

Prakash
  • 100
  • 10