MDI Forms

pramon2003

New member
Joined
Aug 21, 2005
Messages
3
Programming Experience
3-5
Dear Friends

I created a Application with 1 MDI form and 4 child forms with a Menu bar
when i click on the first menu item it will bring the first child form.
if i close that child form by clicking the X red button it will close.
after that if i want bring that form back by clicking the same menu item the form will not show again.

Anyone can help out from this

Mathew
 
Post the code that performs opening of the child form

However, your code should look something like:

Dim nForm as form = new chForm1
nform.MdiParent = Me
nForm.Show()

btw, if you check some boolean operator to be sure that mdi child form will be open only ones note that you should back its value to false on_closed

i.e.

If myBool = false then
myBool = true
nform.Show()
{...}

on_closed event always set up a bool to false
myBool = False

Cheers ;)
 
i wrote the code like this


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim report As New report

report.MdiParent = Me

End sub

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click

Me.report.Show()

End Sub
 
Once you call Close on a form it is Disposed (destroyed) so you cannot call Show again. Also, you are declaring your child form in the Load event handler as a local variable. That means that the "report" variable you are refering to in the first procedure is not the same as the one you are referring to in the second procedure. Forget the first procedure altogether and change the code in the second one to this:
VB.NET:
If Me.report Is Nothing OrElse Me.report.IsDisposed Then
	'The form has either not been created or has been closed so create a new one.
	Me.report = New report
	[b]Me.report.MdiParent = Me 'Edit[/b]
	Me.report.Show()
Else
	'Activate the existing form.
	Me.report.Activate()
End If
 
I'm wondering how it's possible to call the form for the first time at all ... as you have declared "report" with only scope within the Form1_load Sub (after that certain variable will be destroyed)

You should replace the code from Laod event to menuitem9_click and I think it is going to work.

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click

Dim report As New report

report.MdiParent = Me

Me.report.Show()

End Sub

Cheers ;)
 
Back
Top