ContentControlListItem Class
Represents the list item in a drop-down list content control or in a combo box content control.
Inheritance
System.Object
ContentControlListItem
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class ContentControlListItem
Examples
The following example illustrates how to create and manipulate list item in a drop-down list content control or in a combo box 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);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
dropDownList.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";
//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)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim item As New ContentControlListItem()
dropDownList.ParagraphItems.Add(textRange)
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"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Constructors
ContentControlListItem()
Declaration
public ContentControlListItem()
Properties
DisplayText
Gets/Sets the text to be displayed as list item.
Declaration
public string DisplayText { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to access DisplayText property of the list item.
//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);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.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";
//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)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.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"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Value
Gets/Sets the value of the list item.
Declaration
public string Value { get; set; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to set the value of the list item.
//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);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
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";
//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)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
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"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()