vb.net windows forms

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

vb.net
windows form app

I have 2 forms, the first form opens up and there is a button to open the
second form which works fine. I want the second form to have a button to
close the first form.
I tried everything nothing seems to work.. Does anyone know some could I
could use to do this.

Thanks
 
If you are using the "addOwnedForm" method, making Form2 a child of Form1,
you have an automaticly created reference to the parent called "Owner". If
you aren't, then just pass a reference to the second form so you can call
the close method. Here's an example in Pseudocode:

'// within form1
Dim Form2(Me)
Form2.show()


'// within form2
Private mMyOwner as Form1

Publc Sub New()
MyBase.New()
InitializeComponent()
End Sub

Public Sub New(ByRef myOwner as Form1)
MyBase.New()
InitializeComponent()
mMyOwner = myOwner
End Sub

Private Sub btnCloseOwner_Click( ... ) Handles ...
mMyOwner.Close()
End Sub
 
Back
Top