Export (0) Print
Expand All

Troubleshooting Control and Component Authoring

This topic lists common problems that arise when developing components and controls. For more information, see Authoring Components.

Cannot Add Control to Toolbox

If you want to add a custom control that you created in another project or a third-party control to the Toolbox, you must do so manually.

To add a control to the Toolbox

  1. Right-click the Toolbox and choose Add/Remove Items from the shortcut menu.

    The Customize Toolbox dialog box opens.

  2. Add the component:
    • If you want to add a .NET component or control, click the .NET Framework Components tab.

      – or –

    • If you want to add a COM component or ActiveX control, click the COM Components tab.
  3. If your control is listed in the dialog box, make sure it is selected, then click OK.

    The control is added to the Toolbox.

  4. If your control is not listed in the dialog box, do the following:
    1. Click the Browse button.
    2. Browse to the folder that contains the .dll file that contains your control.
    3. Select the control and click Open.

      Your control appears in the dialog box.

    4. Make sure your control is selected, then click OK.

      Your control is added to the Toolbox.

Cannot Debug My Windows Forms User Control or Component

Windows Forms user controls, custom controls, and components are not stand-alone projects. They must be hosted by an application such as a Windows Forms project. To debug a control or component, you must add it to a Windows Forms project.

To debug a control or component

  1. From the Build menu, click Build Solution to build your solution.
  2. From the File menu, choose Add Project then New Project to add a test project to your application.
  3. In the Add New Project dialog box choose Windows Application for the type of project.
  4. Right-click the References node and click Add Reference on the shortcut menu to add a reference to the project containing the control or component.
  5. Create an instance of your control or component in the test project. If your component is in the toolbox, you can drag it to your designer surface, or you can create the instance programmatically as shown in the following example:
    ' Visual Basic
    Dim Component1 As New MyNeatComponent()
    
    // C#
    MyNeatComponent Component1 = new MyNeatComponent();
    

    You can now debug your control or component as normal.

For more information on debugging, see Debugging.

Event Fires Twice in Inherited Control or Component

This is likely due to a duplicated Handles clause. For more information, see Troubleshooting Inherited Event Handlers in Visual Basic .NET.

See Also

Authoring Components | Control Authoring for Windows Forms

Show:
© 2015 Microsoft