D T
D T

Reputation: 3756

How can hide form after form load?

I have 2 forms, in Load event of Form 1: I want open Form 2 and hide Form 1.

This is my code:

Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) 
        Handles MyBase.Load
    If System.IO.File.Exists(autolog) Then    
        Dim frm As New Frm_Main
        frm.Show()
        Me.Hide()         

    End If
End Sub

Result: Form 2 had show, but Form 1 can't hide.

How can hide Form 1?

Upvotes: 0

Views: 109

Answers (1)

MatSnow
MatSnow

Reputation: 7537

The problem here is that you're calling Me.Hide() inside the Load-Method of the Form.
This re-shows the form after the call of Me.Hide() directly.

You can use the Shown-Event of FrmLogin instead.

Upvotes: 2

Related Questions