C # Landing Form jump

Source: Internet
Author: User

We are doing a login screen, click on the login button, we want it to close the form now and then jump to the form we need to sign in to, and we just want to have a form on the desktop instead of overlapping between a form. We do two types of bool in the Login interface class, which is used to sign the form to be landed, and to make two of them public. The main idea is: the landing form as a modal form, and then the landing of the form is set to the main form.

Login form:

Form one:

Form two:

when we click on the form one or the form two buttons in the login interface, we will log on to form one or form two and then close the login screen. But we have to revise the program and login procedures.

Program:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacetest{Static classProgram {/// <summary>        ///The main entry point for the application. /// </summary>[STAThread]Static voidMain () {application.enablevisualstyles (); Application.setcompatibletextrenderingdefault (false); Login Login=NewLogin ();//Create a login formLogin.showdialog ();//display mode login form            if(Login.form1) {Application.Run (NewForm_one ());//take form one main form            }            Else if(Login.form2) {Application.Run (NewForm_two ());//take form two as the main form            }        }    }}

Login:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacetest{ Public Partial classLogin:form {//a global variable for the class that controls the form's main form         Public BOOLForm1 =false;  Public BOOLForm2 =false;  PublicLogin () {InitializeComponent (); }        Private voidButton1_Click (Objectsender, EventArgs e) {Form1=true;  This. Close ();//Close the form now        }        Private voidButton2_Click (Objectsender, EventArgs e) {Form2=true;  This. Close ();//Close the form now        }    }}

C # Landing Form jump

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.