Windows Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on a VB.Net application and am having trouble getting a grasp on
the new way to open and close forms. I understand the object-oriented
approach of .NET, but not fully. I will explain the situation, and if anyone
can point me to any good examples or articles I would appreciate it.
The application starts with a simple "frmLogin" form which asks for the
username/password. Upon entering the correct password, I would like the user
to close this form, and open the "frmMain" form which is the Main form in the
application. What is the best approach to do this?
I had this code:
Dim frm as New frmMain()
frmMain.Show()
Me.Hide()

However, this leaves the "frmLogin" form still open. Is there a way to
close, or get rid of the frmLogin after the user successfully logs in?
Thanks for any help!!
 
There are a lot of ways to do this. Perhaps the easiest way is to make the
main form the default form, and set it to not be visible by default. In it's
Load event handler, show the login screen. If the user successfully logs in,
close the login form and make the main form visible.
 
How do I make the Main Form invisible? I tried calling "Me.Visible = False"
in the Load event, but I guess this is incorrect. Where do I place that
call? Thanks!
 
Try setting it in the contructor (the New() method in VB) before the
InitializeComponent call.
 
Back
Top