简体   繁体   中英

How to open new form when clicked Login button referring the option selected from the combo box

I have a login window where I have 2 sections in combobox which user have to select to what section he/she have to move on. So when user select on option from the combo box and enter the userid and password and click login then he will be moved to a specific form.

IMAGE of the login form:- https://drive.google.com/open?id=19fh710m-9kZU9xXYUFWse8z5d5QZyKMB

protected voud btnLogin_Click (object sender, EventArgs e)
{
   int status = Convert.ToInt32(cbLogin.Value);

   if (status == 1)
     { 
        Form1 frm1 = new Form1(); //Form 1 the name of the form which you want to open.
        frm1.Show();
        this.Hide()
     }

   else if (status == 2)
     {
        From2 frm2 = new Form2(); //Form 2 the name of the form which you want to open.
        frm2.Show();
        this.Hide();
     }

Check the selected value:

if (e.SelectedItem == ?)

Open a new form

new MyForm().Show();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM