C # pass the control as a parameter in winform

Source: Internet
Author: User

Recently I made a winform program design. I need to pass the form control as a parameter to another class function for use. Every time I forget it, I will simply write it down for Instant viewing.

1. Set the modifier attribute of the control to public.

2. Use the space name as the parameter

3. Using system. Windows. forms;

3. In another class, you can directly declare control-type variable columns such as Textbox, savefiledialog, and listview.

In this way, you can remove the form program and operate the control properties of the form in other classes. It also facilitates parameter transfer and mutual control between the form and the form, form and other classes.

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.