Stezzyg
Stezzyg

Reputation: 39

How do I Restart a Form

form1 has a button on it that goes to form2. Form2 has a picturebox with the image of a bird. When the picturebox on form2 is clicked the picturebox disappears and form2 hides itself and form one comes back up. This is a model for a more complicated program but has the same problem. After returning to form1 for the second time if i click the button that brings me to form2 the image of the bird will not show up because form2 returns to its last previous state. What can i do to make form2 refresh / restart / run from the beginning again?

Any help would be appreciated.

Upvotes: 1

Views: 154

Answers (2)

rayncorg
rayncorg

Reputation: 993

you can also use Me.Dispose in every closing_event of your form.

Upvotes: 1

Brad The Developer
Brad The Developer

Reputation: 345

You have two options here.

  1. Destroy form2 completely when you go back to form1 so the next time you go to form2 it's brand new.

  2. When form2 comes into view set the image view back to visible

Update

Here you go.

Dim frm As New Form1
frm.ANewMethod
Set frm = Nothing      ' Form is destroyed.

And here is a link to the documentation http://msdn.microsoft.com/en-us/library/aa242139(v=vs.60).aspx

Upvotes: 3

Related Questions