INFO: Dynamically Adding UserControls that Require Run-Time Licenses

ID: Q241126


The information in this article applies to:
  • Microsoft Visual Basic Professional and Enterprise Editions for Windows, version 6.0


SUMMARY

When a UserControl contains one or more controls that require run-time licenses, the UserControl implicitly becomes a licensed control (requires run-time license). As a result, when you use the Controls.Add method to add the UserControl dynamically, you must precede it by calling the Licenses.Add method and provide the license key for the call.


MORE INFORMATION

If you create a UserControl named, for example, MyProject.MyUserControl, containing one or more controls that require a run-time license, MyProject.MyUserControl acquires a run-time license implicitly. Therefore, if you use the Controls.Add method to add MyProject.MyUserControl dynamically, or call Licenses.Add "MyProject.MyUserControl" without providing the license key, you get the following error:

Run-time error '429': You do not have an appropriate license to use this functionality.
To make this work, you must obtain MyProject.MyUserControl's license key on the development computer as follows:

Debug.Print Licenses.Add ("MyProject.MyUserControl") 
Then, in the client code, you can do the following to dynamically add MyProject.MyUserControl:

Licenses.Add "MyProject.MyUserControl", "License Key"<BR/>
Form1.Controls.Add "MyProject.MyUserControl", "ControlName" 


REFERENCES

For additional information dynamically adding controls, click the article number below to view the article in the Microsoft Knowledge Base:

Q190670 HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0

Additional query words:

Keywords : kbActiveX kbCtrl kbLicensing kbVBp600 kbGrpVB kbDSupport
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: November 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.