Easily understand data interaction between Windows Forms in. net

Source: Internet
Author: User
1. Use constructors with Parameters
2. Pass the value reference and use the parameter reference.
3 is the reference type, one is string, and the other is arraylist
Summary, We use constructors with parameters to implement data interaction between forms, CodeIt seems clear that in the actual development process, dataset, datatable, or dataview can be used as parameters. If you only want to modify a row, you can upload a datarow or datarowview. In the following ArticleTo see how to use the other two methods to achieve data interaction.
1. Use the owner attribute of the Form class

Obtain or set a form that owns the form. To make a form belong to another form, assign a reference to the form that will become the owner for its owner attribute. When a form falls into another form, it is minimized and closed with the owner form. For example, if form2 is owned by the form form1, when form1 is disabled or minimized, form2 is also disabled or minimized. And the affiliated form is never displayed behind the owner form. The affiliated forms can be used to find and replace windows and other windows. When the owner form is selected, these windows should not disappear. To determine the form owned by a parent form, use the ownedforms attribute.

Form2 formchild = new form2 ();

Formchild. Owner = this;
2. Use custom attributes or methods
Iii. use static classes
SummaryIn my opinion, when there are many static classesProgramThe configuration file is loaded into a static class, so that all forms and other instances can use the data through static properties and static methods, such as three-layer structure or multi-layer structure can access it, instead of transmitting data between multiple instances

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.