ControlCollection.RemoveAt(Int32) Method

Definition

Removes the control at the specified index in the ControlCollection instance.

public void RemoveAt(int index);

Parameters

index
Int32

The zero-based index of the control to remove from the ControlCollection instance.

Exceptions

index is less than zero or index is equal to or greater than count.

Examples

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

private void WordControlRemoveAt()
{
    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.RemoveAt(0);
}

Remarks

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

Applies to