Click here to Skip to main content
14,384,575 members
Rate this:
Please Sign up or sign in to vote.
In My project i am having two forms By using Mdi form i am connected those two forms with mdi form It is connected and the problem is once a child form opened and if closed by user and the next time it was not for the both forms what is the problem this my code in mdi parent form of first form
Private Sub EmployeeToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles EmployeeToolStripMenuItem.Click
If f2 Is Nothing Then
f2 = New Empform()
f2.MdiParent = Me

f2.Show()
Else
f2.Activate()
End If

End Sub
for the second form
If f3 Is Nothing Then
f3 = New Party()
f3.MdiParent = Me
f3.Show()
End If
Posted
Comments
CHill60 22-Jan-15 7:04am
   
It is not clear what your problem is. Could you try to explain what happens and how it is different to what you expected to happen?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I'm not entirely sure what you are expecting to happen here, but your code in both cases will only create one instance of each form - it specifically doesn't create a new instance ever again.

So I'm guessing that what happens is:
Create EmpForm as result of menu click.
Use EmpForm.
Use closes EmpForm
User clicks menu again, no new EmpForm is displayed.

And similarly for your Party form.

If that's the case, then when you create your form, you need to add a handler for the FormClosed event and when that event is fired, you set f2 (or f3 as relevant) to Nothing.
That way the second time the menu item is clicked, the code will be able to create a new instance again.

If it isn't that, then you need to explain in better detail exactly what you are trying to achieve and what problem it is giving you.
   
Comments
Member 11390168 27-Jan-15 8:02am
   
thank you for your answer i solved earlier

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100