本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

DocumentBase.Controls 屬性

 

取得包含在文件上的受管理控制項集合。

命名空間:   Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (於 Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public ControlCollection Controls { get; }

屬性值

Type: Microsoft.Office.Tools.Word.ControlCollection

ControlCollection,包含文件上的所有受管理控制項。

A document in an Office solution can contain Windows Forms controls and host controls. For more information, see Controls on Office Documents.

The following code example adds text to the first paragraph and creates a T:Microsoft.Office.Tools.Word.Bookmark control that encompasses the paragraph. The code then shows a message box that displays the total number of controls on the document. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentControls()
{
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.Text = "This is some sample text.";
    this.Controls.AddBookmark(this.Paragraphs[1].Range, "Bookmark1");
    MessageBox.Show("Total number of controls: " +
        this.Controls.Count.ToString());
}
回到頁首
顯示: