WinForm How to take the value of another form in a form

Source: Internet
Author: User

For example, if we define two forms, Form1 and Form2, how do we take a value from Form1 in Form2?

Workaround:

We can define a static variable in the Form2 class MyClass, such as public static string a = "";

Then assign a value to the static variable, for example a = Lblname.text;

Since the scope of a static variable can span a class, in the Form1 method we can call the Form2 static variable a directly using the Form2 class Myclas

MYCLASS.A;

This completes the WinForm to get the value from one form to another;

If there are errors please correct!

WinForm How to take the value of another form in a form

Related Article

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.