Creating ActiveX controls dynamically
-
I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,
-
I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,
Use Load
-
I know how to create an instance of activeX control using CreateObject, but this doesn't exactly display the visual control on the form. It seems like it only creates an object instance of it. How do I make it so that i can switch between activex *visual* controls dynamically on a form? thanks,
Loading ActiveX controls on form dynamically at runtime is not that easy. One way is to declare an object variable. but you cannot handle events for the controls. Other way is to declare a variable as VBControlExtender. u can declare this variables with events. The procedure to use this VBControlExtender:
'place the code in form_load or form_initialize event Dim WithEvents MyCtrl As VBControlExtender 'declaration Licenses.Add "MyCombo.MCombo" 'Add the licence of the control class to the project 'Add the control to the form which is the parent to the control Set MyCtrl = Me.Controls.Add("MyCombo.MCombo", "MyCtrl", Me) 'Set the position of the control and make it visible With MyCtrl .Top = 100 .Width = 100 .Height = 315 .Left = 100 .Visible = True End With
Click event of the control can implemented in this way:Private Sub MyCtrl_ObjectEvent(Info as EventInfo) 'This Info parameter consists of event name and the parameters of the event. If Info.Name = "Click" then 'do your code End If End Sub
that's all Regards, Ravi.