MDI Issues

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2009
Posts: 41
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

MDI Issues

 
0
  #1
May 23rd, 2009
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.
  1. Public Sub tbbCustomer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbbCustomer.Click
  2. Dim CustomerMDIChild As New CustumerRprt()
  3. CustomerMDIChild.MdiParent = Me
  4. CustomerMDIChild.Show()
  5. CustomerMDIChild.Location = New Point(Me.Width / 2 - CustomerMDIChild.Width / 2, Me.Height / 2 - CustomerMDIChild.Height / 2)
  6. End Sub

Q2 here is he code I tried to close form2 and form1.

  1. Public Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
  2.  
  3. If m_ID = 0 Then
  4. Me.Close()
  5. Else
  6. CustumerRprt.Close()
  7. Me.Close()
  8. End If
  9. End Sub
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: MDI Issues

 
0
  #2
May 25th, 2009
use a loop that will check the mdichild's forms then close them and then open the form you wanted to open...
  1. For Each frm As Form In Me.MdiChildren
  2. frm.Close()
  3. Next
  4.  
  5. Dim frm1 As Form1
  6. frm1.Show
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 148
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: MDI Issues

 
0
  #3
May 25th, 2009
Originally Posted by VIPER5646 View Post
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.
try to use ShowDialog() instead of Show() or check for TopMost = True
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 41
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Re: MDI Issues

 
0
  #4
May 25th, 2009
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.
  1. For Each Form In Me.MdiChildren
  2. Form.Close()
  3. Next
  4. Dim CustomerMDIChild As New CustumerRprt()
  5. CustomerMDIChild.MdiParent = Me
  6. CustomerMDIChild.Show()
This coed opens form2.
  1. Design_Report.Show()
How can I close form2 and form1 by just closing form2
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 26
Reputation: Zandermander is an unknown quantity at this point 
Solved Threads: 1
Zandermander Zandermander is offline Offline
Light Poster

Re: MDI Issues

 
0
  #5
May 26th, 2009
For Q2:
In form2, use the FormClosing event to close form1, then form2 will close after.
  1. Private Sub Form2_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
  2. Form1.close
  3. End Sub

-Zander
Last edited by Zandermander; May 26th, 2009 at 5:21 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 41
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Re: MDI Issues

 
0
  #6
May 26th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 26
Reputation: Zandermander is an unknown quantity at this point 
Solved Threads: 1
Zandermander Zandermander is offline Offline
Light Poster

Re: MDI Issues

 
0
  #7
May 27th, 2009
Is form1 set to the form that ends the app?
if it is, try Application.Exit in the form2 closing event.

-Zander
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 148
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: MDI Issues

 
0
  #8
May 27th, 2009
Originally Posted by VIPER5646 View Post
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
I had tried this and works with me.

  1. 'in form2.button_click
  2. Me.Close()
  3. Form1.Close()
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 41
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Re: MDI Issues

 
0
  #9
May 27th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 26
Reputation: Zandermander is an unknown quantity at this point 
Solved Threads: 1
Zandermander Zandermander is offline Offline
Light Poster

Re: MDI Issues

 
0
  #10
May 28th, 2009
Ok.. well try form1.hide maybe.. it doesn't "close it" but it should make it non visable.. can't test it right not.. on my phone when I get to my computer ill try some more things... though im not sure why form1.close won't work...

maybe use the code
  1. form2.button_click
  2. Me.Close()
  3. Form1.Close()

but switch form1.close and me.close

sorry if there are errors in this post. once again.. on my phone.

-Zander
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC