Summary of WinForm Control Development (ii) Use and debug a custom control

Source: Internet
Author: User

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 Application 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, select Choose Items in the pop-up menu ..., and click Browse in the Choose ToolBox Items dialog box that appears ... button, in the Open dialog box, select the DLL generated by our control project (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.

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.