ControlCollection.Remove 方法 (String)

ControlCollection 实例中移除指定的控件。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
Function Remove ( _
    name As String _
) As Boolean
bool Remove(
    string name
)

参数

返回值

类型:System.Boolean

备注

无法从 ControlCollection 实例中移除设计时添加的控件。 只能使用 Remove 方法移除在运行时添加的控件。

示例

下面的代码示例向文档中添加一个 Button 控件和一个 MonthCalendar 控件,然后移除 Button 控件。

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 安全性

请参见

参考

ControlCollection 接口

Remove 重载

Microsoft.Office.Tools.Word 命名空间