Share via


BuildingBlockGalleryContentControl Class (2007 System)

Represents a gallery of document building blocks that users can insert into a document.

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

Syntax

'Declaration
<DefaultBindingPropertyAttribute("Text")> _
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class BuildingBlockGalleryContentControl _
    Inherits ContentControlBase _
    Implements ISupportInitializeControl, ISupportInitialize
'Usage
Dim instance As BuildingBlockGalleryContentControl
[DefaultBindingPropertyAttribute("Text")]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class BuildingBlockGalleryContentControl : ContentControlBase, 
    ISupportInitializeControl, ISupportInitialize
[DefaultBindingPropertyAttribute(L"Text")]
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class BuildingBlockGalleryContentControl sealed : public ContentControlBase, 
    ISupportInitializeControl, ISupportInitialize
public final class BuildingBlockGalleryContentControl extends ContentControlBase implements ISupportInitializeControl, ISupportInitialize

Remarks

A BuildingBlockGalleryContentControl displays a list of document building blocks that users can insert into a document. A document building block is a piece of content that has been created to be used multiple times, such as a common cover page, a formatted table, or a header. To choose the building blocks that you want to display, use the BuildingBlockCategory and BuildingBlockType properties.

For more information about document building blocks, see What's New for Developers in Word 2007.

Content Controls

The BuildingBlockGalleryContentControl is one of eight types of content controls that you can use to design documents and templates in Microsoft Office Word. Content controls have a user interface (UI) that has controlled input like a form. You can use content controls to prevent users from editing protected sections of the document or template, and you can also bind content controls to a data source. For more information, see Content Controls.

Examples

The following code example adds a new BuildingBlockGalleryContentControl to the beginning of the document. The BuildingBlockGalleryContentControl displays equation building blocks that are provided by Microsoft Office Word.

This version is for a document-level customization. To use this code, paste it into the ThisDocument class in your project, and call the AddBuildingBlockControlAtSelection method from the ThisDocument_Startup method.

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

This version is for an application-level add-in. To use this code, paste it into the ThisAddIn class in your project, and call the AddBuildingBlockControlAtSelection method from the ThisAddIn_Startup method.

Dim buildingBlockGalleryControl1 As BuildingBlockGalleryContentControl

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

    Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    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 = this.Application.ActiveDocument.GetVstoObject();
    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;
}

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Tools.Office.RemoteComponent
    Microsoft.VisualStudio.Tools.Office.RemoteBindableComponent
      Microsoft.Office.Tools.Word.ContentControlBase
        Microsoft.Office.Tools.Word.BuildingBlockGalleryContentControl

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

BuildingBlockGalleryContentControl Members

Microsoft.Office.Tools.Word Namespace

Other Resources

Content Controls

How to: Add Content Controls to Word Documents

How to: Protect Parts of Documents by Using Content Controls

Walkthrough: Creating a Template By Using Content Controls

Change History

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.