In the previous article we created a simple control firstcontrol, now let me explain how to use and debug your own controls. I want to write the process as detailed as possible, so that you want to learn the control development of friends easy to use, experts forgive.
Add a Windows Creator project in the same solution (Solution Explorer right click Customcontrolsample Solution Choose Add->new Project ... ), named TestControl. VS will automatically generate a form for you, the file name is Form1.cs. In Solution Explorer, double-click the Form1.cs file to enter the form design interface. Now we add the FirstControl control to the Toolbox (ToolBox), right-click on the ToolBox, and select Choose Items in the pop-up menu ..., click Browse in the Choose ToolBox Items dialog box that appears ... button, select the DLL generated by our control project in the Open dialog box (my DLL is in the F:\programs\c#\customcontrolsample\customcontrolsample\bin\debug directory, You can find it according to the actual situation. Complete this step, in Toolbox will appear we designed the control, the icon is a blue gear (the default is this, of course, you can also modify, the post I will introduce), the name is FirstControl.
Now we select FirstControl in Toolbox, left-click on the form Designer, or hold down the mouse to drag and drop. The controls we made appear on the form designer, select the control on the form designer, and then set the Text property to Hello World in the property browser, and now the text on our control becomes Hello Next we want to run the test project to see the actual effect. Before running, set the test project as startup engineering by right-clicking the TestControl project in Solution Explorer and selecting Set as Startup Project. Click the Run button in the toolbar, or press the F5 function key on the keyboard. The actual effect is shown in the following illustration:
You can set breakpoints to debug your code according to your needs.