officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-contentcontrolcollection-dot-insertdatepickercontrol-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-x29.md
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
ContentControlDate InsertDatePickerControl(
DocumentPosition position
)
Function InsertDatePickerControl(
position As DocumentPosition
) As ContentControlDate
| Name | Type | Description |
|---|---|---|
| position | DocumentPosition |
The document position where the content control should be located.
|
| Type | Description |
|---|---|
| ContentControlDate |
The date picker content control.
|
The code sample below creates a date picker control:
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 });
}
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
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
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
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
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