Freigeben über


ComboBoxContentControl.DropDownListEntries-Eigenschaft (2007 System)

Aktualisiert: Juli 2008

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

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

Syntax

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

Eigenschaftenwert

Typ: Microsoft.Office.Interop.Word.ContentControlListEntries

Ein ContentControlListEntries-Objekt, das die Elemente enthält, die vom ComboBoxContentControl angezeigt werden.

Hinweise

Wenn Sie einem Dokument ein ComboBoxContentControl hinzufügen, 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 ComboBoxContentControl hinzugefügt. Die Benutzer können einen vom Steuerelement angezeigten Farbnamen auswählen oder den Namen einer neuen Farbe eingeben. In diesem Beispiel wird die DropDownListEntries-Eigenschaft verwendet, um die vom Steuerelement angezeigten Farbnamen anzugeben.

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 AddComboBoxControlAtSelection-Methode auf.

Dim comboBoxControl1 As Microsoft.Office.Tools.Word.ComboBoxContentControl

Private Sub AddComboBoxControlAtSelection()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Select()
    comboBoxControl1 = Me.Controls.AddComboBoxContentControl("comboBoxControl1")
    With comboBoxControl1
        .DropDownListEntries.Add("Red", "Red", 0)
        .DropDownListEntries.Add("Green", "Green", 1)
        .DropDownListEntries.Add("Blue", "Blue", 2)
        .PlaceholderText = "Choose a color, or enter your own"
    End With
End Sub
private Microsoft.Office.Tools.Word.ComboBoxContentControl comboBoxControl1;

private void AddComboBoxControlAtSelection()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Select();

    comboBoxControl1 = this.Controls.AddComboBoxContentControl("comboBoxControl1");
    comboBoxControl1.DropDownListEntries.Add("Red", "Red", 0);
    comboBoxControl1.DropDownListEntries.Add("Green", "Green", 1);
    comboBoxControl1.DropDownListEntries.Add("Blue", "Blue", 2);
    comboBoxControl1.PlaceholderText = "Choose a color, or enter your own";
}

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 AddComboBoxControlAtSelection-Methode auf.

Dim comboBoxControl1 As Microsoft.Office.Tools.Word.ComboBoxContentControl

Private Sub AddComboBoxControlAtSelection()
    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()
    comboBoxControl1 = vstoDoc.Controls.AddComboBoxContentControl("comboBoxControl1")
    With comboBoxControl1
        .DropDownListEntries.Add("Red", "Red", 0)
        .DropDownListEntries.Add("Green", "Green", 1)
        .DropDownListEntries.Add("Blue", "Blue", 2)
        .PlaceholderText = "Choose a color, or enter your own"
    End With
End Sub
private Microsoft.Office.Tools.Word.ComboBoxContentControl comboBoxControl1;

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

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

    comboBoxControl1 = vstoDoc.Controls.AddComboBoxContentControl(
        "comboBoxControl1");
    comboBoxControl1.DropDownListEntries.Add("Red", "Red", 0);
    comboBoxControl1.DropDownListEntries.Add("Green", "Green", 1);
    comboBoxControl1.DropDownListEntries.Add("Blue", "Blue", 2);
    comboBoxControl1.PlaceholderText = "Choose a color, or enter your own";            
}

Berechtigungen

Siehe auch

Referenz

ComboBoxContentControl-Klasse

ComboBoxContentControl-Member

Microsoft.Office.Tools.Word-Namespace

Änderungsprotokoll

Date

Versionsgeschichte

Grund

Juli 2008

Version des Codebeispiels für ein Add-In auf Anwendungsebene hinzugefügt.

SP1-Featureänderung.