For the project I am working on, the Startup Form (called HomeForm
) needs to be invisible until the user has logged in to the program. Now I have set it up so that the form is not visible by setting HomeForm.Visible = False
in the Login Form's Load
method.
Private Sub LoginForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
HomeForm.Visible = False
End Sub
I am trying to set it up this way so that when the user logs out, the form also disappears.
Private Sub File_Logout_Click(sender As Object, e As EventArgs) Handles File_Logout.Click
If MessageBox.Show("Are you sure you wish to log out?", "Logout Confirmation", MessageBoxButtons.YesNoCancel) = DialogResult.Yes Then
LoggedIn = False
LoginForm.ShowDialog()
End If
End Sub
Now I am having a small issue where on start up, HomeForm
quickly flashes on screen before becoming invisible. How do I stop this from happening?
I've tried setting Me.Visible = False
in both the constructor and Load
methods of HomeForm
and that didn't accomplish anything. So I am unsure how to solve this problem.
Public Sub New()
InitializeComponent()
Me.Visible = False
End Sub
Private Sub HomeForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Visible = False
LoginForm.ShowDialog()
End Sub