2013-02-14 184 views
-2

我在我的項目中做了15個表格,之後我通過給予屬性isMDIparent true從家裏形成一個父母MDI。現在我想使所有窗體都成爲家庭窗體的子窗體,但是我沒辦法做,所以請建議我將所有表單分配給parentMDI home窗體的子窗體的代碼。如何使用MDI父窗體制作mdi子窗體?

回答

0

您需要將子窗體的MdiParent Property設置爲您的MdiContainer。此示例假定兩個表單中一個名爲Form1,另一個名爲Form2。所有屬性都以編程方式設置。

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 
0

我覺得Mr.Mark廳錯過1個屬性.., 試試這個.......

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 
1

這裏的答案,直接從微軟:

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

0

這實際上是這樣的:

Private sub new() 

Dim c as form1 = new form1<br /> 
c.owner = Me<br /> 
c.MdiParent = Me<br /> 
c.show 

End sub 

InitializeComponent()正如其說,它初始化component.It不是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 

試試這個傢伙......這裏是代碼打開一個窗體作爲MDI的父母來自vb.net的孩子的MDI子。

相關問題