Main Form Code
private void frmMain_Load(object sender, EventArgs e)
{
this.Hide();
DialogResult dr;
frmLogin lStudent = new frmLogin();
dr = lStudent.ShowDialog(this);
lStudent.Dispose();
if (dr != System.Windows.Forms.DialogResult.OK)
this.Dispose();
else
this.Show();
}
Login Form Code
string u = "tochal",p="1357";
if (txtUserName.Text == u && p == txtPassword.Text)
{
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Dispose();
}