Debugging the Control

After you have built your control, you test and debug the control to ensure that it operates as you designed it. To do this, add your control to the Toolbox, add a form to the project, and then add the control to the form. For the GroupCheck scenario, you also add controls to the GroupCheck control, add an event handler for the control's custom events, and then build and run the control.

Adding the Control to the Toolbox

After you have built your control, you add it to the Toolbox in order to use it.

To add the control to the Toolbox

  1. Right-click the ToolBox, and click Customize Toolbox.

  2. Click the WFC Controls tab, and select the name of your control.

    For this scenario, click the GroupCheck control.

  3. Click OK.

Adding a Form to the Project

To test and debug your control, you add a form to your project.

To add a form to your project

  1. In Project Explorer, right-click the name of your project, point to Add, and then click Add Form.

  2. Click the Form icon.

  3. In the Name box, type a name for the form.

    Ensure that the name of the form is not GroupCheck so that the form's source file does not conflict with the name of your control.

  4. Click Open.

    A form is added to your project with the name that you specified and is opened in the Forms Designer.

Adding the Control to the Form

To test the control, you add the control to a form.

To add your control to a form

  1. Select the form.

  2. In the Toolbox, double-click your control.

    The control is added to the center of the form.

Adding Controls to the GroupCheck Control

To ensure that the GroupCheck control is properly parenting controls that are added to it, you add other WFC controls to the GroupCheck control.

To add other controls to the GroupCheck control

  1. On the form, select the GroupCheck control.

  2. In the Toolbox, double-click a control to add the specified control to the center of the GroupCheck control.

Creating Event Handlers

The GroupCheck control contains a custom event called checkedChanged. This event is triggered when the CheckBox control that is contained in the GroupCheck control is either checked or unchecked. To determine whether the event is being triggered properly, you add an event handler for the checkedChanged event to your form.

To add an event handler for the checkedChange event

  1. In the Properties window, click the Events toolbar button.

  2. To display the events of the GroupCheck control, select either the GroupCheck control on the form or the name of the control in the Properties window.

  3. Double-click the checkedChanged event to create an event handler with the default method name.

    The Text editor opens to an empty event handler.

To determine whether the checkedChanged event is being triggered, add code to the event handler for the form that displays a message box each time the event is triggered.

To add code for the event handler

Building and Testing the Control

After you have added the control to a form, added controls to the GroupCheck control, and added an event handler for the control's checkedChanged event, you build and run the project.

To build and run the form

  1. On the Build menu, click Build. (If you receive any compilation errors or messages, correct the errors and rebuild your project.)

  2. To run the form, click Start on the Debug menu.

    Because you are running your project for the first time and because your project contains two .java files, the Project Properties dialog box is displayed.

  3. On the Launch tab, select the Default option button.

  4. Specify that Form1 should load when the project runs, and click OK.

    For more information about project properties, see Setting Project Options.

While the project is running, you can manipulate the control to determine whether it operates properly.

To test the control at run time

For information on exporting a WFC control as an ActiveX control see Building ActiveX Controls.