<p>I'm attempting to create a Wizard type control in VB6 and have run into a stumbling block.</p>

<p>I'd like to allow users of the control to be able to add and manage CWizardPage(s) to the design time control using a property page.</p>

<p>The first approach I used was to add the Wizard pages to the OCX directly using a Collection, however I ran into two problems in that the Collection class is not persistable (and I couldn't find an easy way to make it so) and that VB6 seems very limited in it's ability to instantiate controls at run time - so it would seem to be a struggle to actually re-instantiate them.</p>

<p>My next thought was to just allow the users to draw the wizard pages at design time. This sort of works, however it's far too easy to draw one of the wizard pages inside another wizard page instead of inside the CWizardContainer.</p>

<p>So can anyone please tell me how to add controls to a form at design time without using drag 'n' drop?</p>

You can dynamically add controls to a form or other container (such as a UserControl) using the
```
Add
```
method of the container's
```
Controls
```
collection. For example, to add a TextBox named
```
myTextBox
```
to a form called frmMyForm, you could do this:
```
frmMyForm.Controls.Add "VB.TextBox", "myTextBox"
```
Here is a snippet from the VB6 help file:
Add Method (Controls Collection)
Adds a control to the
Controls
collection and returns a reference to
  the control.
Syntax
object
.
Add
(***ProgID, name, container*
)**
The
Add
method syntax has these parts:
object
(Required)
An object expression that evaluates to
  an object in the
Applies To
list.
ProgID
(Required)
A string that
  identifies the control. The ProgID of
  most controls can be determined by
  viewing the Object Browser. The ProgID
  is composed of the Library and Class
  of the control. For example, the
  CommandButton control's ProgID is
  VB.CommandButton. In cases where the
  ProgID differs from that shown in the
  Object Browser, Visual Basic displays
  an error message that contains the
  correct ProgId.
name
(Required)
A string that identifies the member of
  the collection.
container
(Optional)
An object reference that specifies a
  container of the control. If not
  specified or NULL, defaults to the
  container to which the Controls
  collection belongs. You can put a
  control in any existing container
  control (such as the Frame control) by
  specifying this argument. A user
  control or an ActiveX document can
  also be a container.