Export (0) Print
Expand All

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)

public void Remove (
	string name
)

Parameters

name

The name of the control to be removed from the ControlCollection instance.

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

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

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");
}

Show:
© 2014 Microsoft