Back to Devexpress

ContentControlCollection.InsertDatePickerControl(DocumentPosition) Method

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

latest5.8 KB
Original Source

ContentControlCollection.InsertDatePickerControl(DocumentPosition) Method

Creates a date picker 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
ContentControlDate InsertDatePickerControl(
    DocumentPosition position
)
vb
Function InsertDatePickerControl(
    position As DocumentPosition
) As ContentControlDate

Parameters

NameTypeDescription
positionDocumentPosition

The document position where the content control should be located.

|

Returns

TypeDescription
ContentControlDate

The date picker content control.

|

Example

The code sample below creates a date picker control:

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

using (var wordProcessor = new RichEditDocumentServer()){

    wordProcessor.CreateNewDocument();
    Document document = wordProcessor.Document;
    var contentControls = document.ContentControls;

    var datePicker = contentControls.InsertDatePickerControl(document.Range.Start);
    datePicker.Date = DateTime.Now;
    datePicker.DateFormat = "dddd, MMMM dd, yyyy";
    datePicker.Color = System.Drawing.Color.RebeccaPurple;
    wordProcessor.SaveDocument("Content Controls Date Picker.docx", DocumentFormat.Docx);

    Process.Start(new ProcessStartInfo("Content Controls Date Picker.docx") { UseShellExecute = true });
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()

  wordProcessor.CreateNewDocument()
  Dim document As Document = wordProcessor.Document
  Dim contentControls = document.ContentControls

  Dim datePicker = contentControls.InsertDatePickerControl(document.Range.Start)
  datePicker.Date = Date.Now
  datePicker.DateFormat = "dddd, MMMM dd, yyyy"
  datePicker.Color = System.Drawing.Color.RebeccaPurple
  wordProcessor.SaveDocument("Content Controls Date Picker.docx", DocumentFormat.Docx)

  Process.Start(New ProcessStartInfo("Content Controls Date Picker.docx") With {.UseShellExecute = True})
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertDatePickerControl(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#L40

csharp
var datePosition = document.CreatePosition(document.Paragraphs[2].Range.End.ToInt() - 1);
var datePicker = contentControls.InsertDatePickerControl(datePosition);
datePicker.DateFormat = "dddd, MMMM dd, yyyy";

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

csharp
var datePosition = document.CreatePosition(document.Paragraphs[2].Range.End.ToInt() - 1);
var datePicker = contentControls.InsertDatePickerControl(datePosition);
datePicker.DateFormat = "dddd, MMMM dd, yyyy";

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

csharp
var datePosition = document.CreatePosition(document.Paragraphs[2].Range.End.ToInt() - 1);
var datePicker = contentControls.InsertDatePickerControl(datePosition);
datePicker.DateFormat = "dddd, MMMM dd, yyyy";

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

vb
Dim datePosition = document.CreatePosition(document.Paragraphs(CInt((2))).Range.[End].ToInt() - 1)
Dim datePicker = contentControls.InsertDatePickerControl(datePosition)
datePicker.DateFormat = "dddd, MMMM dd, yyyy"

See Also

ContentControlCollection Interface

ContentControlCollection Members

DevExpress.XtraRichEdit.API.Native Namespace