ContentControlListItems Class
Represents the collection of ContentControlListItem for drop-down and combo box content control.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class ContentControlListItems : IEnumerable
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 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
ContentControlListItems()
Declaration
public ContentControlListItems()
Properties
Count
�Returns the count of ContentControlListItem's collection.
Declaration
public int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to get the count of ContentControlListItem in the collection.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Get the count of content control list items
int count = block.ContentControlProperties.ContentControlListItems.Count;
//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 WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Get the count of content control list items
Dim count As Integer = block.ContentControlProperties.ContentControlListItems.Count
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Item[Int32]
�Gets the list items of the drop-down list or combo-box content control..
Declaration
public ContentControlListItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type |
---|
ContentControlListItem |
Examples
The following code illustrates how to get ContentControlListItem from collection based on specified index.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
block.ContentControlProperties.ContentControlListItems.Add(item1);
//Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
//Get the ContentControlListItem from the collection
block.ContentControlProperties.ContentControlListItems[1].DisplayText = "Fruits";
block.ContentControlProperties.ContentControlListItems[1].Value = "Fruits";
//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 WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
block.ContentControlProperties.ContentControlListItems.Add(item1)
'Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
'Get the ContentControlListItem from the collection
block.ContentControlProperties.ContentControlListItems(1).DisplayText = "Fruits"
block.ContentControlProperties.ContentControlListItems(1).Value = "Fruits"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Methods
Add(ContentControlListItem)
Adds ContentControlListItem to the collection.
Declaration
public void Add(ContentControlListItem item)
Parameters
Type | Name | Description |
---|---|---|
ContentControlListItem | item | ListItem to be added |
Examples
The following code illustrates how to add ContentControlListItem to the collection.
//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)
dropDownList.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()
Insert(Int32, ContentControlListItem)
Inserts the ContentControlListItem at the specified index.
Declaration
public void Insert(int index, ContentControlListItem item)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index in which ContentControlListItem to be inserted. |
ContentControlListItem | item | ContentControlListItem to be inserted |
Examples
The following code illustrates how to insert ContentControlListItem to the collection
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
//Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
//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 WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
'Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Remove(ContentControlListItem)
Removes the specified ContentControlListItems from the collection.
Declaration
public void Remove(ContentControlListItem item)
Parameters
Type | Name | Description |
---|---|---|
ContentControlListItem | item | ContentControlListItem to be removed. |
Examples
The following code illustrates how to remove the specified ContentControlListItem from the collection.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.Remove(item1);
//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 WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.Remove(item1)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
RemoveAt(Int32)
Removes ContentControlListItems from the collection at specified collection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | ContentControlListItem's index to be removed. |
Examples
The following code illustrates how to remove ContentControlListItem from the collection at specified index.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.RemoveAt(0);
//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 WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control");
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.RemoveAt(0)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns ContentControlListItems as a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. |