MDI Issues
I have two Issue using a MDI app.
1-at this moment I'm able to open MDI child forms using the MDIparent
except when the I opens form1 I'm also able to open forms 2
and 3 .
but I only want one form to be open at a time.
2- The next issue is I have form 2 to be opened from form1 and I would like to close form2 and form1 when click close on form2. At this moment I have to close form2 then click close on form1.
Thank you
code for Q1 This is the code on the MDIparent to open the forms.
Public Sub tbbCustomer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbbCustomer.Click
Dim CustomerMDIChild As New CustumerRprt()
CustomerMDIChild.MdiParent = Me
CustomerMDIChild.Show()
CustomerMDIChild.Location = New Point(Me.Width / 2 - CustomerMDIChild.Width / 2, Me.Height / 2 - CustomerMDIChild.Height / 2)
End Sub
Q2 here is he code I tried to close form2 and form1.
Public Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If m_ID = 0 Then
Me.Close()
Else
CustumerRprt.Close()
Me.Close()
End If
End Sub
VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
Thanks Jireh and samir_ibrahim for your replies.
The first Issue has been solved.
I still need more help with the second Issue.
This is the coed I used to open form1.
For Each Form In Me.MdiChildren
Form.Close()
Next
Dim CustomerMDIChild As New CustumerRprt()
CustomerMDIChild.MdiParent = Me
CustomerMDIChild.Show()
This coed opens form2.
Design_Report.Show()
How can I close form2 and form1 by just closing form2
VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
I have tried your code but I'm still unsuccessful. Still can't close form1. form2 closes but not form1.
When I click the Close button it jumps to the closing sub (your code)
but does not close form 1.
Help
VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
Thank you for your replies but it still isn't solved.
To Zandermander your code worked but it closes the entire appl. and I only want form1 and 2 to close.
To Samir_Ibrahim yes I have tried your coed and it did not work.
It closes only form1 but it does not close form2
VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
thanks all for your help.
I have a solution for my Issue.
In form1 I have the following code.
Form2.myParentForm = Me
Form2.Show()
and in form2 this
Public myParentForm As Form
Me.Close()
If (Me.myParentForm IsNot Nothing) Then
Me.myParentForm.Close()
End If
VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2