i have a login form. After doing login one mdi form opens. I want to close login form after opening the mdi form. How can i do this?
there is my code
private void button1_Click(object sender, EventArgs e)
{
MDIParent1 mdi = new MDIParent1();
ClsUserBO bo = new ClsUserBO();
List
bo.Login_ID = txtlogin.Text;
bo.User_Pass = txtpass.Text;
list = ClsUserBL.checklogin(bo);
if (list.Count > 0)
{
//MDIParent1 mdi = new MDIParent1();
if (Login.IsFormAlreadyOpen(typeof(MDIParent1)) == null)
{
Login l = new Login();
mdi.Show();
mdi.Activate();
}
else
{
MessageBox.Show("Already Open");
}
}
else
{
MessageBox.Show("Invalid Username or Password");
txtlogin.Text = null;
txtpass.Text = null;
}
}
plz sort out my problem
thanx
sanjay
Hirendra SisodiyaPosted Jul 8, 2010, 10:48 AM
you can use program.cs for managing this like
Supose Form1 is a login form and Form2 is mdi form.
now you can write code in program.cs like:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 login = new Form1();
login.ShowDialog();
if (login.DialogResult == DialogResult.OK)
{
Application.Run(new Form2());
}
else
{
}
}
and write code for login check on the click of button1_Click event of Form1 like:
private void button1_Click_1(object sender, EventArgs e)
{
if (LoginCheck)
{
DialogResult = DialogResult.OK;
this.Close();
}
}
check this
thanks
Please mark as answer if it helps