Cross-form actions

Source: Internet
Author: User

Users UUU =NewUsersdata (). Selectuser (uname, PWD); When you cross a form, the first form closes, but once you close the first form, the second one closes, because the main form is closed, and the rest of the subform closes, so you can use the control's amount property to hide it, for example: Form2 F2=NewForm2 (); F2.                Show ();  This. Visible =false; In the second one, the first form is manipulated through the second form Form1 F1=NULL;  PublicForm2 (Form1 F1) {InitializeComponent (); F1=F1; Label1. Text= U.nickname +", welcome you! ";        F5 (); A trigger event for the second formPrivate voidForm2_formclosing (Objectsender, FormClosingEventArgs e) {F1.    Close (); Note: You cannot write F1 because of a scope problem, so you need to define an F first, and then let F=F, so you can do it with F. Finally, add the parameter this Form2 F2=NewForm2 ( This); F2.                Show ();  This. Visible =false; Because you want to display the second form of XXX welcome, you need to pass in the constructor the parameters of the Users class U, and, not U. UserName, but a nickname, pay attention to using Label1. Text Receive Form1 F1=NULL;  PublicForm2 (Form1 F1, Users u) {initializecomponent (); F1=F1; Label1. Text= U.nickname +", welcome you! ";        F5 (); Then the first form will not be a parameter, and there should be a Form2 F2=NewForm2 ( This, UUU); F2.                Show ();  This. Visible =false; Instantiate a form threePrivate voidButton1_Click (Objectsender, EventArgs e) {FORM3 F3=NewFORM3 ( This); Notice here the this F3.        Show (); }                       Public Partial classform3:form {Form2 F2=NULL;  PublicForm3 (Form2 F2) {InitializeComponent (); F2=F2; }        Private voidtextBox1_TextChanged (Objectsender, EventArgs e) {            strings =TextBox1.Text; F2.label2.Text=s; }
Users UUU =NewUsersdata (). Selectuser (uname, PWD); When you cross a form, the first form closes, but once you close the first form, the second one closes, because the main form is closed, and the rest of the subform closes, so you can use the control's amount property to hide it, for example: Form2 F2=NewForm2 (); F2.                Show ();  This. Visible =false; Visible: Determines whether the control is displayed or hidden (in the behavior of the property) if the second one is closed, then the first one is not closed, so it cannot be closed, then the first form should be manipulated in the second through the second form, then you need to use the from in the property behavior. Closing), the class name and parameters of the first form are passed in the constructor of the second form, Form1 F1=NULL;  PublicForm2 (Form1 F1) {InitializeComponent (); F1=F1; Label1. Text= U.nickname +", welcome you! ";        F5 (); Then double-click the point fromclosing in the trigger event of the second form,Private voidForm2_formclosing (Objectsender, FormClosingEventArgs e) {F1.    Close (); Note: You cannot write F1 because of a scope problem, so you need to define an F first, and then let F=F, so you can use F and then write F1.close (); Just close the first form before closing the second form, and finally add the parameter this here, which represents the first form, in which case it represents which, and the next step is the The first form is written, because it is click on the first form to open the second form, so instantiate the second form: Form2 F2=NewForm2 ( This); F2.                Show ();  This. Visible =false; Because you want to display the second form of XXX welcome, you need to pass in the constructor the parameters of the Users class U, and, not U. UserName, but a nickname, pay attention to using Label1. Text Receive Form1 F1=NULL;  PublicForm2 (Form1 F1, Users u) {initializecomponent (); F1=F1; Label1. Text= U.nickname +", welcome you! ";        F5 (); Then the first form will not be a parameter, and there should be a Form2 F2=NewForm2 ( This, UUU); F2.                Show ();  This. Visible =false; Click the Second form, open a third form, and make the second form Label1. Text changes in real time with the combobox.text of the third form first writes the Click event in the button of the second form, instantiates the form threePrivate voidButton1_Click (Objectsender, EventArgs e) {FORM3 F3=NewFORM3 ( This); F3.        Show (); Then find the textbox1 in the text box in form three. Textchanged, Public Partial classform3:form {Form2 F2=NULL;  PublicForm3 (Form2 F2) {InitializeComponent (); F2=F2; }        Private voidtextBox1_TextChanged (Objectsender, EventArgs e) {            strings =TextBox1.Text; F2.label2.Text=s; }

Cross-form actions

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.