ControlCollection.Remove Method (String)

Removes the specified control from the ControlCollection instance.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
Function Remove ( _
    name As String _
) As Boolean
bool Remove(
    string name
)

Parameters

Return Value

Type: System.Boolean
Returns Boolean.

Remarks

Controls that were added at design time cannot be removed from the ControlCollection instance. You can use the Remove method only to remove controls added at run time.

Examples

The following code example adds a Button control and a MonthCalendar control to the document, and then removes the Button control.

Private Sub WordControlRemove()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Button1 As Microsoft.Office.Tools.Word.Controls.Button _
        = Me.Controls.AddButton(0, 0, 56.25F, 17.25F, "Button1")
    Dim MonthCalendar1 As Microsoft.Office.Tools.Word.Controls. _
        MonthCalendar = Me.Controls.AddMonthCalendar(0, 20, _
        75, 15, "MonthCalendar1")
    Me.Controls.Remove("Button1")
End Sub
private void WordControlRemove()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Controls.Button button1 =
        this.Controls.AddButton(0, 0, 56.25F, 17.25F,
        "button1");
    Microsoft.Office.Tools.Word.Controls.MonthCalendar
         monthCalendar1 = this.Controls.AddMonthCalendar(
         0, 20, 75, 15, "monthCalendar1");
    this.Controls.Remove("button1");
}

.NET Framework Security

See Also

Reference

ControlCollection Interface

Remove Overload

Microsoft.Office.Tools.Word Namespace