Freigeben über


DropDownListContentControl.DropDownListEntries-Eigenschaft

Ruft die Auflistung von Elementen ab, die vom DropDownListContentControl angezeigt werden.

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

Syntax

'Declaration
ReadOnly Property DropDownListEntries As ContentControlListEntries
ContentControlListEntries DropDownListEntries { get; }

Eigenschaftswert

Typ: Microsoft.Office.Interop.Word.ContentControlListEntries
Ein ContentControlListEntries-Objekt, das die Elemente enthält, die vom DropDownListContentControl angezeigt werden.

Hinweise

Wenn Sie einem Dokument ein DropDownListContentControl, enthält es standardmäßig keine Elemente.Verwenden Sie die Add-Methode der DropDownListEntries-Eigenschaft, um Elemente hinzuzufügen.

Beispiele

Im folgenden Codebeispiel wird am Anfang des Dokuments ein neues DropDownListContentControl hinzugefügt.Im Beispiel wird die DropDownListEntries-Eigenschaft verwendet, um die Namen verschiedener Tage zur Liste der Elemente hinzuzufügen, die Benutzer im Steuerelement auswählen können.

Diese Version bezieht sich auf eine Anpassung auf Dokumentebene.Zum Verwenden dieses Codes fügen Sie ihn in der ThisDocument-Klasse in das Projekt ein und rufen in der ThisDocument_Startup-Methode die AddDropDownListControlAtSelection-Methode auf.

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

Private Sub 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"
    End With
End Sub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;

private void 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";
}

Diese Version bezieht sich auf ein Add-In auf Anwendungsebene.Zum Verwenden dieses Codes fügen Sie ihn in der ThisAddIn-Klasse in das Projekt ein und rufen in der ThisAddIn_Startup-Methode die AddDropDownListControlAtSelection-Methode auf.

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

Private Sub AddDropDownListControlAtSelection()
    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()
    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"
    End With
End Sub
private Microsoft.Office.Tools.Word.DropDownListContentControl dropDownListControl1;

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

    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    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";
}

.NET Framework-Sicherheit

Siehe auch

Referenz

DropDownListContentControl Schnittstelle

Microsoft.Office.Tools.Word-Namespace