Windows Forms

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!!
 
E

Ed Kaim

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

Guest

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!
 
E

Ed Kaim

Try setting it in the contructor (the New() method in VB) before the
InitializeComponent call.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top