BuildingBlockGalleryContentControl 介面

表示使用者可插入文件中的文件建置組塊庫。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
<GuidAttribute("d8d887a2-69fe-4a86-a8dd-352003dc0e7e")> _
Public Interface BuildingBlockGalleryContentControl _
    Inherits ContentControlBase, IBindableComponent, IComponent, IDisposable,  _
    ISupportInitialize
[GuidAttribute("d8d887a2-69fe-4a86-a8dd-352003dc0e7e")]
public interface BuildingBlockGalleryContentControl : ContentControlBase, 
    IBindableComponent, IComponent, IDisposable, ISupportInitialize

BuildingBlockGalleryContentControl 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Application 取得 Microsoft.Office.Interop.Word.Application,代表 Microsoft Office Word 目前的執行個體。
公用屬性 BindingContext 取得或設定 IBindableComponent 的 Currency 管理員集合。 (繼承自 IBindableComponent)。
公用屬性 BuildingBlockCategory 取得或設定在 BuildingBlockGalleryContentControl 中顯示的建置組塊分類。
公用屬性 BuildingBlockType 取得或設定在 BuildingBlockGalleryContentControl 中顯示的建置組塊型別。
公用屬性 Container 基礎架構。 (繼承自 ContentControlBase)。
公用屬性 ContainerComponent 基礎架構。 (繼承自 ContentControlBase)。
公用屬性 Creator 取得 32 位元整數,該整數表示用來建立 BuildingBlockGalleryContentControl 的應用程式。
公用屬性 DataBindings 取得這個 IBindableComponent 的資料繫結物件集合。 (繼承自 IBindableComponent)。
公用屬性 DefaultDataSourceUpdateMode 取得或設定 ContentControlBase 的預設 DataSourceUpdateMode。 (繼承自 ContentControlBase)。
公用屬性 DefaultTextStyle 取得要用來格式化 BuildingBlockGalleryContentControl 中之文字的字元樣式名稱。
公用屬性 ID 取得識別內容控制項的唯一號碼。 (繼承自 ContentControlBase)。
公用屬性 InnerObject 取得 Microsoft.Office.Tools.Word.ContentControlBase 的基礎 Microsoft.Office.Interop.Word.ContentControl 物件。 (繼承自 ContentControlBase)。
公用屬性 LockContentControl 取得或設定值,這個值指定是否可以從文件中刪除 BuildingBlockGalleryContentControl。
公用屬性 LockContents 取得或設定值,這個值指定是否可以編輯 BuildingBlockGalleryContentControl 的內容。
公用屬性 Parent 取得 BuildingBlockGalleryContentControl 的父代 (Parent)。
公用屬性 ParentContentControl 取得以巢狀方式置於另一個內容控制項中之 BuildingBlockGalleryContentControl 的父內容控制項。
公用屬性 PlaceholderText 取得或設定 BuildingBlockGalleryContentControl 中顯示的文字,直到該文字被使用者動作或其他作業變更為止。
公用屬性 Range 取得表示 BuildingBlockGalleryContentControl 內容的 Range
公用屬性 ShowingPlaceholderText 取得值,這個值表示 BuildingBlockGalleryContentControl 目前是否顯示預留位置文字。
公用屬性 Site 取得或設定與 IComponent 相關聯的 ISite。 (繼承自 IComponent)。
公用屬性 Tag 取得或設定要與 BuildingBlockGalleryContentControl 產生關聯的字串。
公用屬性 Temporary 取得或設定值,這個值指定編輯 BuildingBlockGalleryContentControl 控制項時,是否會從文件中自動刪除此控制項。
公用屬性 Text 取得或設定 BuildingBlockGalleryContentControl 中的文字。
公用屬性 Title 取得或設定 BuildingBlockGalleryContentControl 的標題。

回頁首

方法

  名稱 說明
公用方法 BeginInit 表示物件正在啟動初始設定。 (繼承自 ISupportInitialize)。
公用方法 Copy 將 BuildingBlockGalleryContentControl 從文件複製到 [剪貼簿]。
公用方法 Cut 從文件移除 BuildingBlockGalleryContentControl 並將它加入至 [剪貼簿]。
公用方法 Delete 從文件中刪除動態建立的內容控制項,並從文件中的 ControlCollection 移除這個內容控制項。 (繼承自 ContentControlBase)。
公用方法 Dispose 執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。 (繼承自 IDisposable)。
公用方法 EndInit 表示物件已完成初始設定。 (繼承自 ISupportInitialize)。
公用方法 SetPlaceholderText 顯示 Microsoft.Office.Interop.Word.BuildingBlockRange 或字串中的文字,做為 BuildingBlockGalleryContentControl 中的預留位置文字。

回頁首

事件

  名稱 說明
公用事件 Added 在內容控制項加入至文件之後發生。 (繼承自 ContentControlBase)。
公用事件 BindingContextChanged ContentControlBaseBindingContext 屬性值變更時發生。 (繼承自 ContentControlBase)。
公用事件 ContentUpdating 如果內容控制項已繫結至自訂 XML 組件,只在 Microsoft Office Word 更新內容控制項中的文字之前發生。 (繼承自 ContentControlBase)。
公用事件 Deleting 只在內容控制項從文件中刪除之前發生。 (繼承自 ContentControlBase)。
公用事件 Disposed 表示處理元件的 Disposed 事件的方法。 (繼承自 IComponent)。
公用事件 Entering 當使用者在內容控制項中按一下或以程式設計方式將游標移至內容控制項時發生。 (繼承自 ContentControlBase)。
公用事件 Exiting 當使用者在內容控制項外部按一下或以程式設計方式將游標移至內容控制項外部時發生。 (繼承自 ContentControlBase)。
公用事件 StoreUpdating 只在 Microsoft Office Word 更新已繫結至內容控制項之自訂 XML 組件中的資料之前發生 (也就是,在內容控制項中的文字變更之後)。 (繼承自 ContentControlBase)。
公用事件 Validated 在成功驗證內容控制項時發生。 (繼承自 ContentControlBase)。
公用事件 Validating 驗證內容控制項的內容時發生。 (繼承自 ContentControlBase)。

回頁首

備註

BuildingBlockGalleryContentControl 會顯示使用者可插入文件中的「文件建置組塊」(Document Building Blocks) 清單。 文件建置組塊是已建立、可多次使用的內容片段,例如通用封面頁、格式化的資料表或標頭。 若要選擇您要顯示的建置組塊,請使用 BuildingBlockCategoryBuildingBlockType 屬性。

如需文件建置組塊的詳細資訊,請參閱開發人員可在 Word 2007 中使用的新增功能

注意事項注意事項

此介面是由 Visual Studio Tools for Office Runtime 所實作, 並不能實作於您的程式碼中。 如需詳細資訊,請參閱 Visual Studio Tools for Office Runtime 概觀

內容控制項

BuildingBlockGalleryContentControl 是八種內容控制項型別的其中一個,可用來設計 Microsoft Office Word 中的文件和範本。 內容控制項有一個使用者介面 (UI) 具有像表單一樣的受控制輸入。 您可以使用內容控制項以避免使用者編輯文件或範本中被保護的區段,也可以將內容控制項繫結至資料來源。 如需詳細資訊,請參閱內容控制項

使用方式

本文件說明此型別用於以 .NET Framework 4 為目標之 Office 專案的版本。在以 .NET Framework 3.5 為目標的專案中,此型別可能會有不同的成員,而為此型別提供的程式碼範例可能無法運作。 如需此型別在以 .NET Framework 3.5 為目標之專案中的相關文件,請參閱下列 Visual Studio 2008 文件中的參考章節:https://go.microsoft.com/fwlink/?LinkId=160658 (英文)。

範例

下列程式碼範例會將新的 BuildingBlockGalleryContentControl 加入至文件的開頭。 BuildingBlockGalleryContentControl 會顯示 Microsoft Office Word 所提供的方程式建置組塊 (Building Block)。

這是示範文件層級自訂的版本。 若要使用這段程式碼,請將它貼到專案的 ThisDocument 類別中,並從 ThisDocument_Startup 方法呼叫 AddBuildingBlockControlAtSelection 方法。

Dim buildingBlockGalleryControl1 As Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = Me.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    buildingBlockControl1 = this.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

這是示範應用程式層級增益集的版本。 若要使用這段程式碼,請將它貼到專案的 ThisAddIn 類別中,並從 ThisAddIn_Startup 方法呼叫 AddBuildingBlockControlAtSelection 方法。

Dim buildingBlockGalleryControl1 As BuildingBlockGalleryContentControl

Private Sub AddBuildingBlockGalleryControlAtSelection()
    If Me.Application.ActiveDocument Is Nothing Then
        Return
    End If

    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    vstoDoc.Paragraphs(1).Range.Select()
    buildingBlockGalleryControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl( _
        "buildingBlockGalleryControl1")
    With buildingBlockGalleryControl1
        .PlaceholderText = "Choose an equation"
        .BuildingBlockCategory = "Built-In"
        .BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations
    End With
End Sub
private Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl buildingBlockControl1;

private void AddBuildingBlockControlAtSelection()
{
    if (this.Application.ActiveDocument == null)
        return;

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
    vstoDoc.Paragraphs[1].Range.Select();

    buildingBlockControl1 = vstoDoc.Controls.AddBuildingBlockGalleryContentControl(
        "buildingBlockControl1");
    buildingBlockControl1.PlaceholderText = "Choose an equation";
    buildingBlockControl1.BuildingBlockCategory = "Built-In";
    buildingBlockControl1.BuildingBlockType = Word.WdBuildingBlockTypes.wdTypeEquations;
}

請參閱

參考

Microsoft.Office.Tools.Word 命名空間

其他資源

內容控制項

HOW TO:將內容控制項加入至 Word 文件

HOW TO:使用內容控制項保護文件的部分

逐步解說:使用內容控制項建立範本