Vb.net Question

Preventing to Close the First Form by Closing the Other

Good Morning.

I have a Program that has a 3 Forms and they are.

MainMenu
Form1
Form2


I have a
MenuStrip
in
MainMenu
and when I click it
Form1
will show and the code for that is the Simple
Form1.show
now I have some procedures that has a Connect with
Form2
Lets say I opened
Form2
using
Form1
so the
Form1
is still open and
Form2
is on the Top of it and when Im done in
Form2
I will close it using
Button
named Close.

But my concern here is when I close it the
Form1
automatically Hides and I dont want that to happen.

Here is my Code in
Button
Close

'Do some MySQL Command
Me.close


My Question here is that How can I prevent the first Form from Hiding when the Second Form closes. Usually it happens when theres a changes in the Second Form.

I hope someone helps me with this one. TYSM for future help.

Answer

First of all you did not mentioned any code that navigate forms.

As per your information provided, I have put some code that may help you.

Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    Form1.BringToFront()
End Sub

Put above mentioned code in Form2 code.

If you want to stop minimizing Form1 on Form2 close then you can use following code.

Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    Form1.WindowState=FormWindowState.Maximized     
    Form1.BringToFront()
End Sub