usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacewindowsformsapplication8{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidtextBox1_TextChanged (Objectsender, EventArgs e) { } Private voidButton1_Click (Objectsender, EventArgs e) { if(TextBox1.Text = ="Feng"&& TextBox2.Text = ="123") {Form2 F2=NewForm2 ( This); F2. Show (); This. Hide (); } Else{MessageBox.Show ("wrong input! "); return; } } }}
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacewindowsformsapplication8{ Public Partial classform2:form {Form1 F1; PublicForm2 (Form1 F1)//Form Pass -through value{InitializeComponent (); F1=F1; } Private voidForm2_formclosed (Objectsender, Formclosedeventargs e) {F1. Close ();//when the Form2 is closed, Form1 shuts down simultaneously.} List<Form> list =NewList<form>(); Private voidButton1_Click (Objectsender, EventArgs e) { BOOLhas =false; FORM3 f3=NewFORM3 ( This); F3. Owner= This; foreach(Form Finchlist) { if(F.name = = F3. Name)//determine if the form is available{ has=true;//If you have the form, recordF.windowstate = Formwindowstate.normal;//form start General sizeF.show ();//Existing forms displayF3. Close ();//The new form closesF.activate ();//Activate the form and assign it to the form } } if(Has = =false)//If the form is not{F3. Show ();//Create a form that displays a form3List. Add (F3);//add a form3 form into the list collection } } //when the Form3 form is closed, the Form3 form is removed from the list collection Public voiddeleteform3 (Form3 f3) {List<Form> aa=NewList<form>(); foreach(Form Finchlist) { if(f.name!=F3. Name) {aa. ADD (f); }} List=AA; } }}
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacewindowsformsapplication8{ Public Partial classform3:form {Form2 F2; PublicForm3 (Form2 F2) {InitializeComponent (); F2=F2; } Private voidForm3_formclosing (Objectsender, FormClosingEventArgs e) {F2.DELETEFORM3 ( This);//Remove FORM3 Form } }}
Close the main process and popup unique forms