Partilhar via


DropDownListContentControl.DropDownListEntries A propriedade (sistema de 2007)

Obtém a coleção de itens exibidos pelo DropDownListContentControl.

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

Sintaxe

<TypeConverterAttribute("Microsoft.VisualStudio.OfficeTools.Word2007.Design.DropDownListConverter, Microsoft.VisualStudio.Tools.Office.Designer.Office2007, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")> _
Public ReadOnly Property DropDownListEntries As ContentControlListEntries

Dim instance As DropDownListContentControl
Dim value As ContentControlListEntries

value = instance.DropDownListEntries
[TypeConverterAttribute("Microsoft.VisualStudio.OfficeTools.Word2007.Design.DropDownListConverter, Microsoft.VisualStudio.Tools.Office.Designer.Office2007, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public ContentControlListEntries DropDownListEntries { get; }

Valor de propriedade

Tipo: Microsoft.Office.Interop.Word.ContentControlListEntries
A ContentControlListEntries objeto que contém os itens que são exibidos pela DropDownListContentControl.

Comentários

Quando você adiciona um DropDownListContentControl para um documento, ele não contém itens por padrão. Para adicionar itens, use o Add método para o DropDownListEntries propriedade.

Exemplos

O exemplo de código a seguir adiciona um novo DropDownListContentControl para o início do documento. O exemplo usa o DropDownListEntries propriedade para adicionar os nomes de vários dias à lista de itens que os usuários podem selecionar no controle.

Esta versão é para uma personalização em nível de documento.Para usar esse código, cole-o no ThisDocument classe em seu projeto e a telefonar a AddDropDownListControlAtSelection método a partir do ThisDocument_Startup método.

Dim dropDownListControl1 As Microsoft.Office.Tools.Word.DropDownListContentControl

PrivateSub AddDropDownListControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    dropDownListControl1 = Me.Controls.AddDropDownListContentControl("dropDownListControl1")
    With dropDownListControl1
        .DropDownListEntries.Add("Monday", "Monday", 0)
        .DropDownListEntries.Add("Tuesday", "Tuesday", 1)
        .DropDownListEntries.Add("Wednesday", "Wednesday", 2)
        .PlaceholderText = "Choose a day"EndWithEndSub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;

privatevoid AddDropDownListControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    dropDownListControl1 = this.Controls.AddDropDownListContentControl("dropDownListControl1");
    dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
    dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
    dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
    dropDownListControl1.PlaceholderText = "Choose a day";
}

Esta versão é para um suplemento no nível de aplicativo.Para usar esse código, cole-o no ThisAddIn classe em seu projeto e a telefonar a AddDropDownListControlAtSelection método a partir do ThisAddIn_Startup método.

Dim dropDownListControl1 As Microsoft.Office.Tools.Word.DropDownListContentControl

PrivateSub AddDropDownListControlAtSelection()
    IfMe.Application.ActiveDocument IsNothingThenReturnEndIfDim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
    vstoDoc.Paragraphs(1).Range.Select()
    dropDownListControl1 = vstoDoc.Controls.AddDropDownListContentControl("dropDownListControl1")
    With dropDownListControl1
        .DropDownListEntries.Add("Monday", "Monday", 0)
        .DropDownListEntries.Add("Tuesday", "Tuesday", 1)
        .DropDownListEntries.Add("Wednesday", "Wednesday", 2)
        .PlaceholderText = "Choose a day"EndWithEndSub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;

privatevoid AddDropDownListControlAtSelection()
{
    if (this.Application.ActiveDocument == null)
        return;

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

    dropDownListControl1 = vstoDoc.Controls.AddDropDownListContentControl("dropDownListControl1");
    dropDownListControl1.DropDownListEntries.Add("Monday", "Monday", 0);
    dropDownListControl1.DropDownListEntries.Add("Tuesday", "Tuesday", 1);
    dropDownListControl1.DropDownListEntries.Add("Wednesday", "Wednesday", 2);
    dropDownListControl1.PlaceholderText = "Choose a day";
}

Permissões

Consulte também

Referência

DropDownListContentControl Classe

Membros DropDownListContentControl

Namespace Microsoft.Office.Tools.Word