Class InlineContentControl
Represents a inline content control in the Word document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class InlineContentControl : ParagraphItem, IXDLSSerializable, IWidget, IOfficeRun, IInlineContentControl, IParagraphItem, IEntity
Constructors
InlineContentControl(WordDocument, ContentControlType)
Initializes a new instance of the InlineContentControl class.
Declaration
public InlineContentControl(WordDocument doc, ContentControlType controlType)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | doc | The Word document. |
ContentControlType | controlType | The content control type. |
Examples
The following example illustrates how to initializes a new instance of the InlineContentControl.
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds 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()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
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()
Properties
BreakCharacterFormat
Gets the character format of the content control. Read-only.
Declaration
public WCharacterFormat BreakCharacterFormat { get; }
Property Value
Type | Description |
---|---|
WCharacterFormat | The WCharacterFormat object that specifies the character format. |
ContentControlProperties
Gets the content control properties. Read-only.
Declaration
public ContentControlProperties ContentControlProperties { get; }
Property Value
Type | Description |
---|---|
ContentControlProperties | The ContentControlProperties object that specifies the content control properties. |
Examples
The following example illustrates how to set the properties for content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds 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()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
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()
EntityType
Gets the type of the entity.
Declaration
public override EntityType EntityType { get; }
Property Value
Type | Description |
---|---|
EntityType | The EntityType of the current item. |
Overrides
ParagraphItems
Gets the content control paragraphitems. Read-only.
Declaration
public ParagraphItemCollection ParagraphItems { get; }
Property Value
Type | Description |
---|---|
ParagraphItemCollection | The ParagraphItemCollection of the current control. |
Examples
The following example illustrates how to set the properties for content control.
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds 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()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
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()
Methods
CloneImpl()
Creates a duplicate of the entity.
Declaration
protected override object CloneImpl()
Returns
Type |
---|
System.Object |
Overrides
CreateLayoutInfo()
Declaration
protected override void CreateLayoutInfo()