DatePickerContentControl Interface
Represents a date picker control on a document.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)
Syntax
'Declaration
<GuidAttribute("96344f0e-9431-43c6-92bd-8c8621fe1520")> _
Public Interface DatePickerContentControl _
Inherits ContentControlBase, IBindableComponent, IComponent, IDisposable, _
ISupportInitialize
[GuidAttribute("96344f0e-9431-43c6-92bd-8c8621fe1520")]
public interface DatePickerContentControl : ContentControlBase,
IBindableComponent, IComponent, IDisposable, ISupportInitialize
The DatePickerContentControl type exposes the following members.
Properties
Name | Description | |
---|---|---|
Application | Gets a Application that represents the current instance of Microsoft Office Word. | |
BindingContext | Gets or sets the collection of currency managers for the IBindableComponent. (Inherited from IBindableComponent.) | |
Container | Infrastructure. (Inherited from ContentControlBase.) | |
ContainerComponent | Infrastructure. (Inherited from ContentControlBase.) | |
Creator | Gets a 32-bit integer that indicates the application in which the DatePickerContentControl was created. | |
DataBindings | Gets the collection of data-binding objects for this IBindableComponent. (Inherited from IBindableComponent.) | |
DateCalendarType | Gets or sets the type of calendar that is displayed in the DatePickerContentControl. | |
DateDisplayFormat | Gets or sets a string that specifies the format in which the DatePickerContentControl displays dates. | |
DateDisplayLocale | Gets or sets the language format of the date that is displayed in the DatePickerContentControl. | |
DateStorageFormat | Gets or sets the format in which the DatePickerContentControl saves dates in a custom XML part. | |
DefaultDataSourceUpdateMode | Gets or sets the default DataSourceUpdateMode for the ContentControlBase. (Inherited from ContentControlBase.) | |
DefaultTextStyle | Gets the name of the character style that is used to format text in the DatePickerContentControl. | |
ID | Gets a unique number that identifies the content control. (Inherited from ContentControlBase.) | |
InnerObject | Gets the underlying ContentControl object for the Microsoft.Office.Tools.Word.ContentControlBase. (Inherited from ContentControlBase.) | |
LockContentControl | Gets or sets a value that specifies whether the DatePickerContentControl can be deleted from the document. | |
LockContents | Gets or sets a value that specifies whether the contents of the DatePickerContentControl can be edited. | |
MultiLine | Gets or sets a value that specifies whether the DatePickerContentControl can contain line breaks. | |
Parent | Gets the parent of the DatePickerContentControl. | |
ParentContentControl | Gets the parent content control of a DatePickerContentControl that is nested in another content control. | |
PlaceholderText | Gets or sets the text that is displayed in the DatePickerContentControl until the text is changed by a user action or some other operation. | |
Range | Gets a Range that represents the contents of the DatePickerContentControl. | |
ShowingPlaceholderText | Gets a value that indicates whether the DatePickerContentControl is currently displaying placeholder text. | |
Site | Gets or sets the ISite associated with the IComponent. (Inherited from IComponent.) | |
Tag | Gets or sets a string that you want to associate with the DatePickerContentControl. | |
Temporary | Gets or sets a value that specifies whether the DatePickerContentControl is automatically deleted from the document when the control is edited. | |
Text | Gets or sets the text in the DatePickerContentControl. | |
Title | Gets or sets the title of the DatePickerContentControl. | |
XMLMapping | Gets an XMLMapping that represents the binding between the DatePickerContentControl and an element in a custom XML part. |
Top
Methods
Name | Description | |
---|---|---|
BeginInit | Signals the object that initialization is starting. (Inherited from ISupportInitialize.) | |
Copy | Copies the DatePickerContentControl from the document to the Clipboard. | |
Cut | Removes the DatePickerContentControl from the document and adds it to the Clipboard. | |
Delete | Deletes a dynamically created content control from the document and removes it from the ControlCollection in the document. (Inherited from ContentControlBase.) | |
Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.) | |
EndInit | Signals the object that initialization is complete. (Inherited from ISupportInitialize.) | |
SetPlaceholderText | Displays text that is in a BuildingBlock, a Range, or a string as the placeholder text in the DatePickerContentControl. |
Top
Events
Name | Description | |
---|---|---|
Added | Occurs after the content control is added to the document. (Inherited from ContentControlBase.) | |
BindingContextChanged | Occurs when the value of the BindingContext property of the ContentControlBase changes. (Inherited from ContentControlBase.) | |
ContentUpdating | Occurs 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.) | |
Deleting | Occurs just before the content control is deleted from the document. (Inherited from ContentControlBase.) | |
Disposed | Represents the method that handles the Disposed event of a component. (Inherited from IComponent.) | |
Entering | Occurs when the user clicks in the content control, or when the cursor is moved into the content control programmatically. (Inherited from ContentControlBase.) | |
Exiting | Occurs when the user clicks outside the content control, or when the cursor is moved outside the content control programmatically. (Inherited from ContentControlBase.) | |
StoreUpdating | Occurs 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.) | |
Validated | Occurs when the content control has been successfully validated. (Inherited from ContentControlBase.) | |
Validating | Occurs when the contents of the content control are being validated. (Inherited from ContentControlBase.) |
Top
Remarks
A DatePickerContentControl provides a calendar that enables users to select a date. The calendar appears when the end user clicks the drop-down arrow in the control.
To specify the format of the date that is displayed, use the DateDisplayFormat and DateDisplayLocale properties. To choose a regional calendar, use the DateCalendarType property.
Note
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 DatePickerContentControl 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: https://go.microsoft.com/fwlink/?LinkId=160658.
Examples
The following code example adds a new DatePickerContentControl to the beginning of the document. The example also modifies the format in which the control displays dates.
This version is for a document-level customization. To use this code, paste it into the ThisDocument class in your project, and call the AddDatePickerControlAtSelection method from the ThisDocument_Startup method.
Dim datePickerControl1 As Microsoft.Office.Tools.Word.DatePickerContentControl
Private Sub AddDatePickerControlAtSelection()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Me.Paragraphs(1).Range.Select()
datePickerControl1 = Me.Controls.AddDatePickerContentControl("datePickerControl1")
datePickerControl1.DateDisplayFormat = "MMMM d, yyyy"
datePickerControl1.PlaceholderText = "Choose a date"
End Sub
private Microsoft.Office.Tools.Word.DatePickerContentControl datePickerControl1;
private void AddDatePickerControlAtSelection()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
this.Paragraphs[1].Range.Select();
datePickerControl1 = this.Controls.AddDatePickerContentControl("datePickerControl1");
datePickerControl1.DateDisplayFormat = "MMMM d, yyyy";
datePickerControl1.PlaceholderText = "Choose a date";
}
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 AddDatePickerControlAtSelection method from the ThisAddIn_Startup method.
Dim datePickerControl1 As Microsoft.Office.Tools.Word.DatePickerContentControl
Private Sub AddDatePickerControlAtSelection()
If Me.Application.ActiveDocument Is Nothing Then
Return
End If
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
vstoDoc.Paragraphs(1).Range.InsertParagraphBefore()
vstoDoc.Paragraphs(1).Range.Select()
datePickerControl1 = vstoDoc.Controls.AddDatePickerContentControl("datePickerControl1")
datePickerControl1.DateDisplayFormat = "MMMM d, yyyy"
datePickerControl1.PlaceholderText = "Choose a date"
End Sub
private Microsoft.Office.Tools.Word.DatePickerContentControl datePickerControl1;
private void AddDatePickerControlAtSelection()
{
if (this.Application.ActiveDocument == null)
return;
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.Paragraphs[1].Range.InsertParagraphBefore();
vstoDoc.Paragraphs[1].Range.Select();
datePickerControl1 = vstoDoc.Controls.AddDatePickerContentControl("datePickerControl1");
datePickerControl1.DateDisplayFormat = "MMMM d, yyyy";
datePickerControl1.PlaceholderText = "Choose a date";
}
See Also
Reference
Microsoft.Office.Tools.Word Namespace
Other Resources
How to: Add Content Controls to Word Documents
How to: Protect Parts of Documents by Using Content Controls