Iam creating an instance to the main form on login button click and again creating instance to login form on logout button click. my code is
if ((txtU
You need to put your login part in Program.cs , before Application.Run() called e.g :
if (new frmLogin().ShowDialog() == DialogResult.OK)
{
Application.Run(new frmMain());
}
then put login codes in login form. after user logged in, form login will be closed and will set this.dialogresualt = dialogresult.ok; e.g :
if (txtUserName.Text == "blah"
&& txtPassword.Text == "blah")
{
txtPassword.BackColor = Color.YellowGreen;
txtUserName.BackColor = Color.YellowGreen;
this.DialogResult = DialogResult.OK;
}
else
{
txtPassword.BackColor = Color.Salmon;
txtUserName.BackColor = Color.Salmon;
}