Class ContentControlProperties
Represents the formatting options of the content control in the Word document.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class ContentControlProperties : XDLSSerializableBase, IXDLSSerializable
Examples
The following example illustrates how to apply various content control properties.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
richTextControl.ContentControlProperties.Color = Color.Gray;
richTextControl.ContentControlProperties.LockContentControl = true;
richTextControl.ContentControlProperties.Tag = "RichText";
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Add new text to the content control
WTextRange textRange1 = new WTextRange(document);
textRange1.Text = "Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange1);
InlineContentControl textControl = paragraph.Items.LastItem as InlineContentControl;
textControl.ParagraphItems.Add(textRange1);
textControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
textControl.ContentControlProperties.Color = Color.Gray;
textControl.ContentControlProperties.LockContentControl = true;
textControl.ContentControlProperties.LockContents = true;
textControl.ContentControlProperties.Multiline = true;
textControl.ContentControlProperties.Tag = "Text";
textControl.ContentControlProperties.Title = "Text content control";
//Add new date content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
//Add new text to the content control
WTextRange textRange2 = new WTextRange(document);
textRange2.Text = "Date Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange2);
InlineContentControl dateControl = paragraph.Items.LastItem as InlineContentControl;
dateControl.ParagraphItems.Add(textRange2);
dateControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
dateControl.ContentControlProperties.DateCalendarType = CalendarType.GregorianArabic;
dateControl.ContentControlProperties.DateDisplayFormat = "dd yy MMMM";
dateControl.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US;
dateControl.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
dateControl.ContentControlProperties.Tag = "Date control";
dateControl.ContentControlProperties.Title = "Date content control";
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange3 = new WTextRange(document);
textRange3.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
//richTextControl.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Add new picture content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Picture);
Image image = Image.FromFile("Image.png");
IWPicture picture = new WPicture(document);
picture.LoadImage(image);
picture.Height = 100;
picture.Width = 100;
InlineContentControl pictureControl = paragraph.Items.LastItem as InlineContentControl;
pictureControl.ParagraphItems.Add(picture);
pictureControl.ContentControlProperties.Tag = "Picture control";
pictureControl.ContentControlProperties.Title = "picture control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
richTextControl.ContentControlProperties.Color = Color.Gray
richTextControl.ContentControlProperties.LockContentControl = True
richTextControl.ContentControlProperties.Tag = "RichText"
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Add new text to the content control
Dim textRange1 As New WTextRange(document)
textRange1.Text = "Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange1)
Dim textControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
textControl.ParagraphItems.Add(textRange1)
textControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
textControl.ContentControlProperties.Color = Color.Gray
textControl.ContentControlProperties.LockContentControl = True
textControl.ContentControlProperties.LockContents = True
textControl.ContentControlProperties.Multiline = True
textControl.ContentControlProperties.Tag = "Text"
textControl.ContentControlProperties.Title = "Text content control"
'Add new date content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
'Add new text to the content control
Dim textRange2 As New WTextRange(document)
textRange2.Text = "Date Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange2)
Dim dateControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
dateControl.ParagraphItems.Add(textRange2)
dateControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
dateControl.ContentControlProperties.DateCalendarType = CalendarType.GregorianArabic
dateControl.ContentControlProperties.DateDisplayFormat = "dd yy MMMM"
dateControl.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US
dateControl.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate
dateControl.ContentControlProperties.Tag = "Date control"
dateControl.ContentControlProperties.Title = "Date content control"
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange3 As New WTextRange(document)
textRange3.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'richTextControl.ParagraphItems.Add(textRange);
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Add new picture content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Picture)
Dim image As Image = image.FromFile("Image.png")
Dim picture As IWPicture = New WPicture(document)
picture.LoadImage(image)
picture.Height = 100
picture.Width = 100
Dim pictureControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
pictureControl.ParagraphItems.Add(picture)
pictureControl.ContentControlProperties.Tag = "Picture control"
pictureControl.ContentControlProperties.Title = "picture control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Properties
Appearance
Gets or sets a value indicating the appearance of the content control. The default value is ContentControlAppearance.BoundingBox.
Declaration
public ContentControlAppearance Appearance { get; set; }
Property Value
Type |
---|
ContentControlAppearance |
Remarks
Use BoundingBox type to display the contents of content control within a box. Use Tags type to display the contents of content control within tags. Use Hidden type to display the contents of content control without any box or tags.
Examples
The following example illustrates how to change the appearance of content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
//Sets Tag appearance for the content control.
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Tag appearance for the content control.
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
CheckedState
Declaration
public CheckBoxState CheckedState { get; set; }
Property Value
Type |
---|
CheckBoxState |
Color
Gets or sets a value indicating the color of the content control.
Declaration
public Color Color { get; set; }
Property Value
Type |
---|
Color |
Examples
The following example illustrates how to change the color of content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets the Color property of content control.
richTextControl.ContentControlProperties.Color = Color.Blue;
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets the Color property of content control.
richTextControl.ContentControlProperties.Color = Color.Blue
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
ContentControlListItems
Gets or sets values indicating the items in a drop-down list content control or in a combo box content control
Declaration
public ContentControlListItems ContentControlListItems { get; }
Property Value
Type |
---|
ContentControlListItems |
Examples
The following example illustrates how to set the ContentControlListItems for Combo-box and Drop-down content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
//Set default option in drop down list.
WTextRange textRange = new WTextRange(document);
textRange.Text = "Choose an item";
dropDownList.ParagraphItems.Add(textRange);
//Add item into drop down list.
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "DocIO";
//Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
//Add item into drop down list.
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "PDF";
//Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
//Add combo box control.
IInlineContentControl comboboxControl = paragraph.AppendInlineContentControl(ContentControlType.ComboBox);
//Set default option in Combo box.
textRange = new WTextRange(document);
textRange.Text = "Choose an item";
comboboxControl.ParagraphItems.Add(textRange);
//Add item into combo box list.
item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Windows";
//Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item);
//Add another item into combo box list.
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Xamarin";
//Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Set default option in drop down list.
Dim textRange As New WTextRange(document)
textRange.Text = "Choose an item"
dropDownList.ParagraphItems.Add(textRange)
'Add item into drop down list.
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "DocIO"
'Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
'Add item into drop down list.
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "PDF"
'Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
'Add combo box control.
Dim comboboxControl As IInlineContentControl = paragraph.AppendInlineContentControl(ContentControlType.ComboBox)
'Set default option in Combo box.
textRange = New WTextRange(document)
textRange.Text = "Choose an item"
comboboxControl.ParagraphItems.Add(textRange)
'Add item into combo box list.
item = New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Windows"
'Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item)
'Add another item into combo box list.
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Xamarin"
'Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
DateCalendarType
Gets or sets a value indicating the calendar type for a Date picker content control.
Declaration
public CalendarType DateCalendarType { get; set; }
Property Value
Type |
---|
CalendarType |
Examples
The following example illustrates how to set calendar type for the Date picker content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets calendar type for the date picker control.
datePicker.ContentControlProperties.DateCalendarType = CalendarType.Gregorian;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets calendar type for the date picker control.
datePicker.ContentControlProperties.DateCalendarType = CalendarType.Gregorian
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
DateDisplayFormat
Gets or sets a value indicating the format in which dates are displayed in Date picker content control.
Declaration
public string DateDisplayFormat { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following example illustrates how to set date display format for the Date picker content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets format for date to display.
datePicker.ContentControlProperties.DateDisplayFormat = "M/d/yyyy";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
datePicker.ContentControlProperties.DateDisplayFormat = "M/d/yyyy"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
DateDisplayLocale
Gets or sets a value indicating the language format for the date displayed in a Date picker content control.
Declaration
public LocaleIDs DateDisplayLocale { get; set; }
Property Value
Type |
---|
LocaleIDs |
Examples
The following example illustrates how to set date display locale for the Date picker content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets the language format for the date.
datePicker.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets the language format for the date.
datePicker.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
DateStorageFormat
Gets or sets a value indicating the storage and retrieval of dates when a date content control is bound to the XML data storage.
Declaration
public ContentControlDateStorageFormat DateStorageFormat { get; set; }
Property Value
Type |
---|
ContentControlDateStorageFormat |
Examples
The following example illustrates how to set format for date display locale for the Date picker content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets the storage and retrieval format for the date.
datePicker.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets the storage and retrieval format for the date.
datePicker.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
HasPlaceHolderText
Gets a value indicating whether the placeholder text for the content control is displayed or not.
Declaration
public bool HasPlaceHolderText { get; }
Property Value
Type |
---|
System.Boolean |
IsChecked
Gets or sets the current state of the Check box content control.
Declaration
public bool IsChecked { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsTemporary
Gets or sets a value indicating whether to remove a content control from the Word document when the user edits the contents of the control
Declaration
public bool IsTemporary { get; set; }
Property Value
Type |
---|
System.Boolean |
LockContentControl
Gets or sets a value indicating whether the user can delete a content control from the active Word document
Declaration
public bool LockContentControl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
The following example illustrates how to lock the content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Enables content control lock.
richTextControl.ContentControlProperties.LockContentControl = true;
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Enables content control lock.
richTextControl.ContentControlProperties.LockContentControl = True
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
LockContents
Gets or sets a value indicating whether the user can edit the contents of a content control.
Declaration
public bool LockContents { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
The following example illustrates how to set Temporary property of the content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.RichText);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
richTextControl.ParagraphItems.Add(textRange);
//Protects the content control.
richTextControl.ContentControlProperties.LockContents = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
richTextControl.ParagraphItems.Add(textRange)
'Protects the content control.
richTextControl.ContentControlProperties.LockContents = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Multiline
Gets or sets a value indicating whether a text content control allows multiple lines of text. This property is applicable only for Plain text content control.
Declaration
public bool Multiline { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
The following example illustrates how to set Multiline property of Plain text content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text);
InlineContentControl plainTextControl = paragraph.Items.LastItem as InlineContentControl;
//Enables multiline for plain text control.
plainTextControl.ContentControlProperties.Multiline = true;
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Plain Text Content Control";
plainTextControl.ParagraphItems.Add(textRange);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text)
Dim plainTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Enables multiline for plain text control.
plainTextControl.ContentControlProperties.Multiline = True
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Plain Text Content Control"
plainTextControl.ParagraphItems.Add(textRange)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Tag
Gets or sets a value to identify the content control
Declaration
public string Tag { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following example illustrates how to set the tag property for the content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Tag property of the content control.
richTextControl.ContentControlProperties.Tag = "RichText";
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Tag property of the content control.
richTextControl.ContentControlProperties.Tag = "RichText"
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Title
Gets or sets a value indicating the title of the content control
Declaration
public string Title { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following example illustrates how to set the title property for the content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Type
Gets the type of the content control.
Declaration
public ContentControlType Type { get; }
Property Value
Type |
---|
ContentControlType |
Examples
The following example illustrates how to get type of content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Plain Text");
//Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text);
InlineContentControl inlineContentControl = paragraph.Items.LastItem as InlineContentControl;
//Gets the type of content control.
ContentControlType controlType = inlineContentControl.ContentControlProperties.Type;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Plain Text")
'Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text)
Dim inlineContentControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Gets the type of content control.
Dim controlType As ContentControlType = inlineContentControl.ContentControlProperties.Type
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
UncheckedState
Declaration
public CheckBoxState UncheckedState { get; set; }
Property Value
Type |
---|
CheckBoxState |
XmlMapping
Declaration
public XmlMapping XmlMapping { get; }
Property Value
Type |
---|
XmlMapping |
Methods
CloneImpl()
Creates a duplicate of the entity.
Declaration
protected object CloneImpl()
Returns
Type |
---|
System.Object |