Step 2: generate and test controls
Now the design of the TrafficLight control is complete. Select Build | Build MyControls (generate | generate MyControls) to create the final control Library.
To test the control, we need a Windows Form project. You can perform this operation in other solutions, but it is easier to do it in the solution used by the development control. Select File | Add Project | New Project (File | Add Project | New Project) from the menu ). Select the Windows Application project type and name the project TestTrafficLight. Click OK to start the Windows application.
You must first place the TrafficLight control in the toolbox to drag it to blank form 1 of the test application. Right-click the Windows Forms tab in the Toolbox, and select Customize Toolbox ). Select the. NET Framework Components (. NET Framework component) tab, and click the Browse button. Browse to the location of your MyControls project and go to the/bin directory of the project. Select the MyControls. dll component and click OK ). Now, the dialog box is shown in figure 2.
Figure 2: In the Customize Toolbox dialog box, the TrafficLight control is selected.
You can see a check mark next to the TrafficLight control. Click OK. On the Windows Forms tab of the toolbox, the TrafficLight control appears at the bottom of the control list. Figure 3 shows the toolbox of the TrafficLight control at the bottom.
Figure 3: TrafficLight control at the bottom of the toolbox
Now, you can drag the TrafficLight control to the blank form 1 of TestTrafficLight. By default, it is named TrafficLight1. You can adjust the widget size and reset its properties, including the Status attribute. This property has a drop-down menu that contains three possible values of this property. Note that when you adjust the widget size or its properties, the widget is automatically refreshed in the designer.
To restore the default value of a property, change the Status property to statusRed. Right-click the Status attribute in the Properties window and select Reset, as shown in figure 4. This property will be changed back to statusGreen. If you set the BorderWidth attribute to a value other than 1, you can use the same method to restore its default value.
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