共用方式為


BuildingBlockGalleryContentControl.PlaceholderText Property

Gets or sets the text that is displayed in the BuildingBlockGalleryContentControl until the text is changed by a user action or some other operation.

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

Syntax

'Declaration
Property PlaceholderText As String
string PlaceholderText { get; set; }

Property Value

Type: System.String
The text that is displayed in the control until the text is changed by a user action or some other operation.

Remarks

The placeholder text is displayed until a user selects a building block or the control is populated with data from a data source.

To set the placeholder text to text that is in a BuildingBlock or a Range, use the SetPlaceholderText method.

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. The example sets the PlaceholderText property to a string that prompts the user to choose an equation.

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

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

.NET Framework Security

See Also

Reference

BuildingBlockGalleryContentControl Interface

Microsoft.Office.Tools.Word Namespace