The first use is to put a form on another form, such as code, and later found that it is very card, the interface to move or adjust will not come back.
// basicin bi = new Basicin (a); // bi. TopLevel = false; // to load the form when the control must be // splitcontainer3.panel1.controls.clear (); // splitcontainer3.panel1.controls.add (BI); // bi. Dock = DockStyle.Fill; // bi. BringToFront (); // this.ds = bi; // bi. Show ();
Therefore, use the user control instead.
First, the steps to make a user control
1, create a new project, File New project.
2, add the new item user control.
3. Set the code you need.
4. Run the program. Locate the appropriate. dll file under the Debug folder.
Second, there are two ways to use a user control
1. Locate the. dll file. In the Toolbox, right-click on "select". NET Framework Components Browse, locate the. dll file to add, the Toolbox will automatically display the user control, just drag and drop it. Cons: The need to modify the user control is to rebuild the DLL file, trouble.
2, right-click on your own project's solution add the existing item, add the user control, and use the edge to change.
All right.
If you want to pass the value of the window to the user control,
1,get,set method.
User controls:
Public Static string NULL ; Public void Setlab (string _tipdou) { = _tipdou; ShowData (Tipdou); } Public Static string Getlab () { return Tipdou; }
Window:
Usercontrol11.setlab ("a");
2, method parameter pass value,,,
User controls:
public void AddData (string b)
{
Sarrry = Mystr.split (new char[] {' * '}, 7, stringsplitoptions.none);
if (b = = "Style")
{
This.adddatarow ();
}
if (b = = "Color")
{
This.adddatarow1 ();
}
if (b = = "Size")
{
This.adddatarow2 ();
}
}
Window:
Usercontrol11.adddata ("a");
C#winform making user controls + passing values to user controls