Dynamically Add / Load Usercontrol ControlArray in Runtime.
Posted on 2011-02-21
I have a VB6 project in which I have the normal application (forms etc) and 1 usercontrols which I've developed.
I have added one instance of the usercontrol on the form as a control array and dynamically load and place multiple instances of it on the Form as and when required. This is all nice and smooth.
Now I have created a second user control within the project. This user control is essentially the same as the initial usercontrol, sharing the same properties and events. The only exception is the interface. I've made this small and compact - compared to the initial one, which is quite big.
On the application, I allow the users to set their preference on which version of the user control they'd like to see - the Standard or the Compact.
Based on the user preference, I should dynamically load the controls on screen.
On code, I use a control array and have name the control as Cabin1(x), so all manipulations, property changes are for Cabin1(x).
Now what I need to do is, Whatever control the user may select (Standard / Compact), I need that control to have the name Cabin1 and it should be created as a control array, so I can load multiple instances of it in Runtime and reference it as Cabin1(x).
How do I do it?