Question

I'll just get straight to it, I have this code:

Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    startup.Show()
    Me.WindowState = FormWindowState.Minimized
    Me.ShowInTaskbar = False
    Me.Hide()
End Sub

This is going to be the form which loads first, having the entire project shutting down when this form closes (hence why I have to load this form first & calling the startup from this)

After the startup form has finished it's code, I have this code:

    ...
    frmMain.ShowInTaskbar = True
    frmMain.WindowState = FormWindowState.Normal
    Me.Close()

How can I get the main form to load again without actually triggering it's _load event (thus avoiding it to trigger an infinite loop).

Était-ce utile?

La solution

did you mean show the main form?

frmMain.Show()
frmMain.BringToFront()

Autres conseils

Try this in order to show the hidden form:

frmMain.Show()

I'd suggest a better way to tackle this is to show the startup form from the application startup event. Your main form can then be a main form instead of being hidden.

    startup.WindowState = FormWindowState.Normal
    Call startup.Show()
    Call startup.BringToFront()
    Call startup.Activate()

The essential step to unhide from windowstate minimized, which is the windowstate of hidden forms, is to change the windowstate to normal. An example of this is shown in my first line of code. The other lines are for showing, bringing to the front and activating the formerly hidden form with the name startup. Goodluck!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top