Back to Devexpress

ContentControlCollection.InsertDropDownListControl(DocumentPosition) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-contentcontrolcollection-dot-insertdropdownlistcontrol-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-x29.md

latest5.8 KB
Original Source

ContentControlCollection.InsertDropDownListControl(DocumentPosition) Method

Creates a drop-down list content control at the specified document position.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
ContentControlDropDownList InsertDropDownListControl(
    DocumentPosition position
)
vb
Function InsertDropDownListControl(
    position As DocumentPosition
) As ContentControlDropDownList

Parameters

NameTypeDescription
positionDocumentPosition

The document position where the content controls should be located.

|

Returns

TypeDescription
ContentControlDropDownList

The drop-down list content control.

|

Example

The code sample below creates a drop down list content controls:

image

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer()) {
    Document document = wordProcessor.Document;
    var contentControls = document.ContentControls;

    // Insert a drop-down list to select the appointment type:
    var listPosition = document.CreatePosition(document.Paragraphs[2].Range.End.ToInt() - 1);
    var listControl = contentControls.InsertDropDownListControl(listPosition);

    // Add items to the drop-down list:
    listControl.AddItem("First Appointment", "First Appointment");
    listControl.AddItem("Follow-Up Appointment", "Follow-Up Appointment");
    listControl.AddItem("Laboratory Results Check", "Laboratory Results Check");

    listControl.SelectedItemIndex = 1;
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()
    Dim document As Document = wordProcessor.Document
    Dim contentControls = document.ContentControls

    ' Insert a drop-down list to select the appointment type:
    Dim listPosition = document.CreatePosition(document.Paragraphs(2).Range.End.ToInt() - 1)
    Dim listControl = contentControls.InsertDropDownListControl(listPosition)

    ' Add items to the drop-down list:
    listControl.AddItem("First Appointment", "First Appointment")
    listControl.AddItem("Follow-Up Appointment", "Follow-Up Appointment")
    listControl.AddItem("Laboratory Results Check", "Laboratory Results Check")

    listControl.SelectedItemIndex = 1

End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertDropDownListControl(DocumentPosition) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/ContentControlActions.cs#L29

csharp
var listPosition = document.CreatePosition(document.Paragraphs[1].Range.End.ToInt() - 1);
var listControl = contentControls.InsertDropDownListControl(listPosition);

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/ContentControls.cs#L30

csharp
var listPosition = document.CreatePosition(document.Paragraphs[1].Range.End.ToInt() - 1);
var listControl = contentControls.InsertDropDownListControl(listPosition);

word-document-api-examples/CS/CodeExamples/ContentControlsActions.cs#L32

csharp
var listPosition = document.CreatePosition(document.Paragraphs[1].Range.End.ToInt() - 1);
var listControl = contentControls.InsertDropDownListControl(listPosition);

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/ContentControls.vb#L26

vb
Dim listPosition = document.CreatePosition(document.Paragraphs(CInt((1))).Range.[End].ToInt() - 1)
Dim listControl = contentControls.InsertDropDownListControl(listPosition)
' Add items to the drop-down list:

See Also

ContentControlCollection Interface

ContentControlCollection Members

DevExpress.XtraRichEdit.API.Native Namespace