Adding an OCX control to the Design Environment

Top  Previous  Next


The following steps are needed to add your favorite OCX to the Designer IDE. After this, you can populate the target OCX as needed into any Form.



Open a .Net console window and change the directory to the location where you want to create the .Net COM interface.


At the command prompt type:


aximp.exe c:\YourActiveXfilename.ocx.


This will create two files, AxYourActiveXfilename.dll and YourActiveXfilename.dll. Some ActiveX files can also have a DLL extension; for example, shdocvw.dll is the Internet Explorer ActiveX.


aximp.exe is part of the .NET Framework SDK, typically installed in:

C:\Program Files\Microsoft.NET\SDK\v2.0\bin.


If the control is an ActiveX control use aximp.exe. For a regular COM DLL use tlbimp.exe.



Start the IDE and open a project. Activate the Form design window. Right click on one of the tabs in the Toolbox pad and choose Configure Sidebar.



The left-hand pane displays a list of the available categories. You can add the ActiveX component to one of these categories or create a new one. To add a new Category, click the New button in the lower left corner.



Click the Add Components button. Select the Custom tab. Click the button just to the right of the File Name textbox. Use the Open explorer window and select the AxYourActiveXfilename.dll file that you created in Step 1.



The file path and name are now displayed in the File Name textbox. Click the Show Components button. The components should now be displayed in the right-hand pane. Click the OK button.



The ActiveX component is now available on the Category tab you selected. Before you can place an instance of the ActiveX control on your Form, you may have to change the Form's Font.Unit property to Point in the Property pad.



You can now place an instance of the ActiveX control on your Form and have access to the properties and events in the Property pad.


Finally, make sure to add "AxYourActiveXfilename.dll" to the References node in the Project.