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