CtlsAdd (CtlCfg.vbp and CtlView.vbp)

The two sample applications work together to demonstrate dynamic control addition, or the Add Method for the Controls collection. The first sample, CtlCfg.vbp, adds control license keys to the Controls.mdb database using the Licenses.Add method. The second sample, CtlView, uses the information (license keys) stored in the database to dynamically load controls.

File Description
Controls.mdb Access database that holds license key information.
CtlCfg.frm Control configuration form.
CtlCfg.frx Control configuration binary data.
CtlCfg.vbp Control configuration project file.
CtlView.frm Control view form.
CtlView.frx Control view binary data.
CtlView.vbp Control view project file.

To Run

First open and run the CtlCfg.vbp project. If you have any user controls (that require license keys), you can add the keys to the database using the application.

To Add A Control's License Key

  1. Open a second instance of Visual Basic.

  2. Add a user control (that requires a license key) to the Toolbox using the Components dialog box.

  3. Press F2 to display the Object Browser.

  4. In the Object Browser, note the Library and Class name of the control. This is the progID of the control.

  5. Switch to the CtlCfg application.

  6. On the Edit menu, click New Entry.

  7. In the new row, fill in the Description column.

  8. In the ControlType column, type the progID of the user control.

  9. If there is a property of the control you would like to set, type the property name in the PropertyName column. Then type an appropriate value in the PropertyValue column.

  10. In the ControlHeight and ControlWidth columns, type in (optional) values.

  11. On the File menu, click Save. The control's license (if it has one) will appear in the ControlLicense column.

  12. Close the application.

Open and run the CtlView.vbp project. A grid on the form displays the names of controls that can be dynamically added. Click the control name to add it to the form.