Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
 
Share this answer
 
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900