Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Form.ControlCollection.Add Method

Adds a control to the form.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Overrides Sub Add ( _
	value As Control _


Type: System.Windows.Forms.Control

The Control to add to the form.


A multiple document interface (MDI) parent form cannot have controls added to it.

You can use this method to add controls to the form. If you want to add a group of already created controls to the form, use the Control.ControlCollection.AddRange method of the Control.ControlCollection class.

The following code example adds a TextBox and Label control to the control collection of a form. The example requires that a form has been created and named Form1.

Public Sub AddMyControls()
    Dim textBox1 As New TextBox()
    Dim label1 As New Label()

    ' Initialize the controls and their bounds.
    label1.Text = "First Name"
    label1.Location = New Point(48, 48)
    label1.Size = New Size(104, 16)
    textBox1.Text = ""
    textBox1.Location = New Point(48, 64)
    textBox1.Size = New Size(104, 16)

    ' Add the TextBox control to the form's control collection.
    ' Add the Label control to the form's control collection.
End Sub 'AddMyControls

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft