1) Create your log in form as a separate class, derived from Form: call it frmLogin or similar.
2) Create an instance in your main Form Load event.
3) Show the login form as a modal dialog.
4) Check the users responses to ensure his user details are ok.
bool loggedIn = false;
while (!loggedIn)
{
frmLogin f = new frmLogin();
if (frmLogin.ShowDialog == DialogResult.Cancel)
{
Close();
return;
}
if (IsGoodLogin(f.UserName, f.Password))
{
loggedIn = true;
}
}
Then all you have to do is write IsGoodLogin - I can't help as I don't know anything about how you store names and passwords. However there is a note on password storage here:
Password Storage: How to do it.[
^]