Copying Controls From Form to Form

Question:
I have a VB application that contains two forms. Form A is a Control Library that contains several Frames, Labels, Text Boxes, and Command buttons. (Note: some of these controls are third party controls.) Form B is the Main form. This form contains an SSActiveTab, with 4 tabs on it.

What I want to do is make it so that the user selects on tab 1, building a data entry form on tab 2. I know how to collect the desired controls from the Control Library, but how do I paint them onto the Main form tab?

Answer:
In VB6 a Form has a Controls collection which you can add to by passing the progid of the control. If you want to add a control that is not in the control box of the application and you want be able to catch events of the control, then declare a variable as VBControlExtender and set it to point to the control that you added:

Dim objNewControl as VBControlExtenderSet objNewControl=Controls.Add   ("Widget.Thingjet","Widget1")
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: