Compartilhar via


ControlCollection.Remove Method

Definition

Overloads

Remove(String)

Removes the specified control from the ControlCollection instance.

Remove(Object)

Removes the specified control from the ControlCollection instance.

Remove(String)

Removes the specified control from the ControlCollection instance.

public:
 bool Remove(System::String ^ name);
public bool Remove (string name);
abstract member Remove : string -> bool
Public Function Remove (name As String) As Boolean

Parameters

name
String

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

Returns

Returns Boolean.

Examples

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

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.

Applies to

Remove(Object)

Removes the specified control from the ControlCollection instance.

public:
 void Remove(System::Object ^ control);
public void Remove (object control);
abstract member Remove : obj -> unit
Public Sub Remove (control As Object)

Parameters

control
Object

The control to be removed from the ControlCollection instance.

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.

Applies to