As I can use this :
VB Code:
Set Text1 = ctlForm.Controls.Add("VB.TextBox", "TextBox1")
For a textbox, what would be the equivelant to VB.TextBox for a listview? :ehh: It doesn't like VB.ListView...
Printable View
As I can use this :
VB Code:
Set Text1 = ctlForm.Controls.Add("VB.TextBox", "TextBox1")
For a textbox, what would be the equivelant to VB.TextBox for a listview? :ehh: It doesn't like VB.ListView...
Used this : "MSComctlLib.ListViewCtrl.2" :)
Just be aware manavo that since Listview is not an Intrinsic control then you must add license to licenses collection or it may fail on the destination machine otherwise.
Oops :blush: What is that? I read about it but I thought since it worked on my PC it'll work fine :(Quote:
Originally Posted by RhinoBull
It basically means that it much safer to use Control Array with any non Intrinsic control (those that are not part of VB default controls).
Here is a quote from MSDN:
Quote:
Add Method (Licenses Collection)
Adds a license to the Licenses collection and returns the license key.
Syntax
object.Add (ProgID, LicenseKey)
The Add method syntax has these parts:
Part Description
object Required. Anobject expression that evaluates to an object in the Applies To list.
ProgID Required. A string that specifies the control for which a license key will be added.
LicenseKey Optional. A string that specifies the license key.
Remarks
Use the Add method whenever you want to dynamically add a control that requires a license key. For more information about controls that require license keys, see "Licensing Issues for Controls" in the See Also list.
When you compile a user control that requires a license key, and you want to dynamically add that control to an existing application, you must use the Add method for the Licenses collection in two different ways.
First, use the method to return the license key that is hard-coded into a user control. Second, use the method to add the same license key to the Licenses collection before adding the user control to the Controls collection.
In most cases, you will have to use the method in both ways in order to properly deploy a compiled user control. The steps for this are outlined below.
After you have compiled a user control that requires a license key, use the Add method to return the license key. Store that license key where it can be retrieved by the deployed application. For example, the example below writes the key to a file. You could also store it in a database, or in the Windows registry.
When you deploy your control, the deployed application adds the license key to the Licenses collection before adding the control to the Controls collection. (Of course, the control must have been installed on the machine as well.) The code example below adds the license key, then adds the control:VB Code:
Private Sub GenerateLicenseKey() Dim intFile As Integer intFile = FreeFile ' Open a file to write the license key to. Open "c:\Temp\Ctl_Licenses.txt" For Output As #intFile Dim strLicense As String strLicense = Licenses.Add("prjWeeks.WeeksCtl") ' Write the license key to the file. Write #intFile, strLicense Close #intFile End Sub
When To Add a License KeyVB Code:
Option Explicit Dim WithEvents extObj As VBControlExtender Private Sub LoadDynamicControl() Dim intFile As Integer intFile = FreeFile Open "c:\Download\Ctl_Licenses.txt" For Input As #intFile Dim strKey As String ' On the client machine, read the license key from the file. Input #intFile, strKey Licenses.Add "prjWeeks.WeeksCtl", strKey Close #intFile Set extObj = Controls.Add("prjWeeks.WeeksCtl", "ctl1") With Controls("ctl1") .Visible = True End With End Sub
When you create a user control and you want to distribute the control for dynamic control addition, you must consider the following question: Does the user control contain only intrinsic controls? If the answer is yes, then ask, "Do I want to require that the end user have a license key in order to use the control?" If the answer to both questions is "yes," then be sure to check the Require License Key option on the General tab of the Project Properties dialog box.
Note Even if you clear the Require License Key option, a user control that contains third-party controls will still require a license key.
When No License Key Is Needed
There are two circumstances when you do not have to add a license key in order to add a control to the Controls collection:
When the control is an intrinsic control and you have not checked the Require License Key option.
When you add a control that is referenced in the project. In other words, if the control is present in the Toolbox.
Note When you do have a control in the Toolbox and you plan to add that control only at run time, be sure to clear the Remove Information About Unused ActiveX Controls option on the Make tab of the Project Properties dialog box; otherwise, trying to add the control will fail.
I'll have to read through that then... Thanks RB :thumb:
Sure, any time.