Jomar Jomar - 1 year ago 132 Question

Reset windows form without exiting the program

hello all? is there any way to completely reset a form on close or dispose?

I mean when you exit entire program everything will reset right.? so I want that without closing first form but closing only second one should do..!! Thanks

Answer Source

Oh, I misunderstood your question. In that case, you can use ShowDialog in Form1 like so:

Dim Cancel As Boolean = False 'you can set this true using whatever event suits your needs

While Not Cancel
    Using newform2 As New Form2
    End Using

If I'm understanding what you need right, the code above will just keep opening new instances of that form until you tell it to stop. Honestly though, I really think you should consider having the form reset itself instead of closing and reopening it. If the form is coded in a modular way and most (or all) variables are of limited scope, then doing so should not require much code. Hope that helps though

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download