Log in

  • Thread starter Thread starter Max3vil
  • Start date Start date
M

Max3vil

I need to write two forms, frmMain and frmLogin.
I would like to show frmMain after i pres a button in frmLogin.

any ideas ?
tnx
 
Hi Max3vil,

In your Main method you can call frmLogin.ShowDialog and if credentials
are ok, then start frmMain using Application.Run
 
can you giveme an example ?

Morten Wennevik said:
Hi Max3vil,

In your Main method you can call frmLogin.ShowDialog and if credentials
are ok, then start frmMain using Application.Run
 
static void Main()
{
Form1 f = new Form1();

if(f.ShowDialog() == DialogResult.OK)
Application.Run(new Form2(f.UserName));
}


Inside Form1 you set this.DialogResult = DialogResult.OK if the user is
valid (and then call this.Close(). Main then checks if Form1 was closed
with a DialogResult.OK, and if so launches Form2

The UserName part is optional, and only shows that you can pass
information from Form1 to Form2.
 
Back
Top