How to implement communication between form and form in C #

Source: Internet
Author: User

I saw this article on this website todayArticle: "C # How to implement access between two winforms ".CodeThe test can indeed be implemented, but we do not know whether a problem has been found. the person who wrote this article made the problem worse. why. please refer to my solution to this problem.

Everyone knows that object-orientedProgramOne feature of the design is polymorphism. One is encapsulation and the other is inheritance. At last, we do not need to explain it. The implementation method is as follows:

1. inherit a form1 class from form.

2. inherit a form2 class from form.

3. Add a member variable in the form2 class: frmparent

4. Add an overloaded constructor to the form2 class: Public form2 (form1 parent) {frmparent = parent };

5. Add a button object to form1. The corresponding Event code is:

{

Form2 FRM = new form2 (this );
FRM. Show ();
}

6. Add a button object to form2. The corresponding Event code is:

{

Frmparent. Text = "success or failure rewriting ";

}

In this simple way, the communication between form and form is completed. How simple is it, right! I hope I can get to know some C # experts through this article. I am also a C # programmer. I wrote this article because I saw this article leading everyone to the misunderstanding. don't be surprised when I ask the younger brother to see it.

My email is Givectl521@163.com MSN: xyheart_2006@hotmail.com hope to do. NET development friends can make friends, learn from each other.

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.