This is my problem...
I have a form (Form1), which is calling another form(Form2). In this Form2, when I close the Form, I want to call a method of Form1, to change values from Form1 components. The method is called, but the components values of Form1 don't change... I guess this is because when I call the method of Form1 from Form2, it is created anothed Form1 instance, and the method it's not executed in Form1 from which I call Form2
Form1 calling Form2
Private Sub btnCallForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCallForm.Click
frmForm2.ShowDialog()
End Sub
Form2 calling method of Form2
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
frmForm1.ChangeValues()
End Sub
Pass the original instance of
Form1
to the constructor ofForm2
, like this:Now in
Form1
, when you create theForm2
instance you need to pass the instance ofForm1
, like this: