Freigeben über


ControlCollection.RemoveAt Method

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

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

Syntax

'Declaration
Sub RemoveAt ( _
    index As Integer _
)
void RemoveAt(
    int index
)

Parameters

Exceptions

Exception Condition
ArgumentOutOfRangeException

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

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.

Examples

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

Private Sub WordControlRemoveAt()
    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.RemoveAt(0)
End Sub
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);
}

.NET Framework Security

See Also

Reference

ControlCollection Interface

Microsoft.Office.Tools.Word Namespace