Form.Load EventHandler

Hi all

I have a VB.Net windows application with a lot of forms. Form1 and Form2... .Now to navigate between the different forms I use a function which is in a different class.

Function

Comments

  • I assume that you want to 'reset' the form each time you switch, and that's why you want to call the Form.Load event again?
    Easiest solution is to close the form each time when you're done with it and show it again when you need it.
    The fact that the Load event only runs once is to help you be able to hide a form and then bring it back later exactly the way it was before it got hidden. What you want sounds like creating a new form each time.

    Use Show and Close instead of changing visibility.
    [code]
    Public Shared Function displayWindow(ByVal formName As Form) As Form
    formName.Show
    Me.Close
    End Function
    [/code]
    You might have to change the "Shutdown Mode" in project properties to "When last form closes", rather than when starting form closes.

    If I'm wrong and you do want to preserve the state of the form between switches, then the code you need to execute each time that is in the Load event is in the wrong event. Use Activate or something like that instead.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Your assumption was correct BitByBit_Thor I need to
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories