mdi child problem
-
hi.. i have make 3 forms 1 mdi parent and 2 mdi child calling a child to show at parent is easy but hoow to make a child call another child and show it in the parent? this is basically how it look like.. form1(parent) call form2(child)....form2 show in form1 form2(child) call form3(child).....form3 show in form1 i try to code the button in form2 like so Dim frm3 as New Form3 Dim frm1 as New Form1 frm3.mdiparent = frm1 frm3.show which is not working...am i doing it wrong? please help me...thank you in adnvace Gary
-
hi.. i have make 3 forms 1 mdi parent and 2 mdi child calling a child to show at parent is easy but hoow to make a child call another child and show it in the parent? this is basically how it look like.. form1(parent) call form2(child)....form2 show in form1 form2(child) call form3(child).....form3 show in form1 i try to code the button in form2 like so Dim frm3 as New Form3 Dim frm1 as New Form1 frm3.mdiparent = frm1 frm3.show which is not working...am i doing it wrong? please help me...thank you in adnvace Gary
Try this:
Public Class Form1
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim frm2 As New Form2 frm2.MdiParent = Me frm2.Show() End Sub
End Class
Public Class Form2
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm3 As New Form3 frm3.MdiParent = Me.ParentForm frm3.Show() End Sub
End Class
-
Try this:
Public Class Form1
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim frm2 As New Form2 frm2.MdiParent = Me frm2.Show() End Sub
End Class
Public Class Form2
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm3 As New Form3 frm3.MdiParent = Me.ParentForm frm3.Show() End Sub
End Class
tried....but this error show up An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication7.exe Additional information: Object reference not set to an instance of an object. and still unable to show the second child Gary
-
tried....but this error show up An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication7.exe Additional information: Object reference not set to an instance of an object. and still unable to show the second child Gary
Try
Owner
instead ofParentForm
.ParentForm
gets the form on which a control is placed.Owner
should get (if I remember right) the owning form of a child form. -
tried....but this error show up An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication7.exe Additional information: Object reference not set to an instance of an object. and still unable to show the second child Gary
I'm sorry Gary, I tested my previous example on VisualBasic 2005 Beta and it works there. You're right it does produce an error on my VS 2003. I tested this on VS 2003 and it works.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
frm3.MdiParent = Me.MdiParent
frm3.Show()
End Sub -
I'm sorry Gary, I tested my previous example on VisualBasic 2005 Beta and it works there. You're right it does produce an error on my VS 2003. I tested this on VS 2003 and it works.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
frm3.MdiParent = Me.MdiParent
frm3.Show()
End Sub