How can I "unhide" this form without triggering the _load event?

3.3k views Asked by At

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).

4

There are 4 answers

1
Rex On BEST ANSWER

did you mean show the main form?

frmMain.Show()
frmMain.BringToFront()
0
SysDragon On

Try this in order to show the hidden form:

frmMain.Show()
4
peterG On

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.

0
Evert On
    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!