Export (0) Print
Expand All

DropDownListContentControl Interface

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents a drop-down list on a document.

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

[GuidAttribute("ae93cbb1-82a6-4a2b-9540-a0c82ff9ebcb")]
public interface DropDownListContentControl : ContentControlBase, 
	IBindableComponent, IComponent, IDisposable, ISupportInitialize

The DropDownListContentControl type exposes the following members.

  NameDescription
Public propertyApplicationGets a Microsoft.Office.Interop.Word.Application that represents the current instance of Microsoft Office Word.
Public propertyBindingContextGets or sets the collection of currency managers for the IBindableComponent. (Inherited from IBindableComponent.)
Public propertyContainerInfrastructure. (Inherited from ContentControlBase.)
Public propertyContainerComponentInfrastructure. (Inherited from ContentControlBase.)
Public propertyCreatorGets a 32-bit integer that indicates the application in which the DropDownListContentControl was created.
Public propertyDataBindingsGets the collection of data-binding objects for this IBindableComponent. (Inherited from IBindableComponent.)
Public propertyDefaultDataSourceUpdateModeGets or sets the default DataSourceUpdateMode for the ContentControlBase. (Inherited from ContentControlBase.)
Public propertyDefaultTextStyleGets the name of the character style that is used to format text in the DropDownListContentControl.
Public propertyDropDownListEntriesGets the collection of items that are displayed by the DropDownListContentControl.
Public propertyIDGets a unique number that identifies the content control. (Inherited from ContentControlBase.)
Public propertyInnerObjectGets the underlying Microsoft.Office.Interop.Word.ContentControl object for the Microsoft.Office.Tools.Word.ContentControlBase. (Inherited from ContentControlBase.)
Public propertyLockContentControlGets or sets a value that specifies whether the DropDownListContentControl can be deleted from the document.
Public propertyLockContentsGets or sets a value that specifies whether the contents of the DropDownListContentControl can be edited.
Public propertyMultiLineGets or sets a value that specifies whether the DropDownListContentControl can contain line breaks.
Public propertyParentGets the parent of the DropDownListContentControl.
Public propertyParentContentControlGets the parent content control of a DropDownListContentControl that is nested in another content control.
Public propertyPlaceholderTextGets or sets the text that is displayed in the DropDownListContentControl until the text is changed by a user action or some other operation.
Public propertyRangeGets a Range that represents the contents of the DropDownListContentControl.
Public propertyShowingPlaceholderTextGets a value that indicates whether the DropDownListContentControl is currently displaying placeholder text.
Public propertySiteGets or sets the ISite associated with the IComponent. (Inherited from IComponent.)
Public propertyTagGets or sets a string that you want to associate with the DropDownListContentControl.
Public propertyTemporaryGets or sets a value that specifies whether the DropDownListContentControl is automatically deleted from the document when the control is edited.
Public propertyTextGets the text in the DropDownListContentControl.
Public propertyTitleGets or sets the title of the DropDownListContentControl.
Public propertyXMLMappingGets an XMLMapping that represents the binding between the DropDownListContentControl and an element in a custom XML part.
Top

  NameDescription
Public methodBeginInitSignals the object that initialization is starting. (Inherited from ISupportInitialize.)
Public methodCopyCopies the DropDownListContentControl from the document to the Clipboard.
Public methodCutRemoves the DropDownListContentControl from the document and adds it to the Clipboard.
Public methodDeleteDeletes a dynamically created content control from the document and removes it from the ControlCollection in the document. (Inherited from ContentControlBase.)
Public methodDisposePerforms application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Public methodEndInitSignals the object that initialization is complete. (Inherited from ISupportInitialize.)
Public methodSetPlaceholderTextDisplays text that is in a BuildingBlock, a Range, or a string as the placeholder text in the DropDownListContentControl.
Top

  NameDescription
Public eventAddedOccurs after the content control is added to the document. (Inherited from ContentControlBase.)
Public eventBindingContextChangedOccurs when the value of the BindingContext property of the ContentControlBase changes. (Inherited from ContentControlBase.)
Public eventContentUpdatingOccurs just before Microsoft Office Word updates the text in the content control, if the content control is bound to a custom XML part. (Inherited from ContentControlBase.)
Public eventDeletingOccurs just before the content control is deleted from the document. (Inherited from ContentControlBase.)
Public eventDisposedRepresents the method that handles the Disposed event of a component. (Inherited from IComponent.)
Public eventEnteringOccurs when the user clicks in the content control, or when the cursor is moved into the content control programmatically. (Inherited from ContentControlBase.)
Public eventExitingOccurs when the user clicks outside the content control, or when the cursor is moved outside the content control programmatically. (Inherited from ContentControlBase.)
Public eventStoreUpdatingOccurs just before Microsoft Office Word updates data in a custom XML part that is bound to the content control (that is, after the text in the content control changes). (Inherited from ContentControlBase.)
Public eventValidatedOccurs when the content control has been successfully validated. (Inherited from ContentControlBase.)
Public eventValidatingOccurs when the contents of the content control are being validated. (Inherited from ContentControlBase.)
Top

A DropDownListContentControl displays a list of items that users can select.

To access the list of items in a DropDownListContentControl, use the DropDownListEntries property.

To enable users to choose from a list of items or add their own text to the control, use a ComboBoxContentControl.

NoteNote

This interface is implemented by the Visual Studio Tools for Office runtime. It is not intended to be implemented in your code. For more information, see Visual Studio Tools for Office Runtime Overview.

Content Controls

The DropDownListContentControl is one of eight types of content controls that you can use to design documents and templates in Microsoft Office Word. Content controls have a user interface (UI) that has controlled input like a form. You can use content controls to prevent users from editing protected sections of the document or template, and you can also bind content controls to a data source. For more information, see Content Controls.

Usage

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4 and the .NET Framework 4.5. In projects that target the .NET Framework 3.5, this type might have different members and the code examples provided for this type might not work. For documentation about this type in projects that target the .NET Framework 3.5, see the following reference section in the Visual Studio 2008 documentation: http://go.microsoft.com/fwlink/?LinkId=160658.

The following code example adds a new DropDownListContentControl to the beginning of the document. Users can select the name of a day of the week in the control.

This version is for a document-level customization. To use this code, paste it into the ThisDocument class in your project, and call the AddDropDownListControlAtSelection method from the ThisDocument_Startup method.

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

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 AddDropDownListControlAtSelection method from the ThisAddIn_Startup method.

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";
}
Show:
© 2014 Microsoft