BuildingBlockGalleryContentControl.BuildingBlockCategory 属性 (2007 system)

更新: 2008 年 7 月

获取或设置在 BuildingBlockGalleryContentControl 中显示的构造块的类别。

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

语法

声明
Public Property BuildingBlockCategory As String
用法
Dim instance As BuildingBlockGalleryContentControl
Dim value As String

value = instance.BuildingBlockCategory

instance.BuildingBlockCategory = value
public string BuildingBlockCategory { get; set; }

属性值

类型:System.String

BuildingBlockGalleryContentControl 中显示的构造块的类别。

备注

所有构造块都属于一个类别和一个库。使用 BuildingBlockCategory 属性可指定由 BuildingBlockGalleryContentControl 显示的构造块的类别。可将此属性的值设置为 Microsoft Office Word 定义的 Built-In 或 General 类别,也可指定自定义类别。

若要指定在 BuildingBlockGalleryContentControl 中显示哪个构造块库,请使用 BuildingBlockType 属性。

示例

下面的代码示例会在文档开头添加一个新的 BuildingBlockGalleryContentControlBuildingBlockGalleryContentControl 显示由 Microsoft Office Word 提供的方程式生成块。该示例会将 BuildingBlockCategory 属性设置为 Built-In 类别。

此版本针对的是文档级自定义项。若要使用此代码,请将其粘贴到项目内的 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 = 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;
}

权限

另请参见

参考

BuildingBlockGalleryContentControl 类

BuildingBlockGalleryContentControl 成员

Microsoft.Office.Tools.Word 命名空间

修订记录

日期

修订记录

原因

2008 年 7 月

添加了一个针对应用程序级外接程序的代码示例版本。

SP1 功能更改。