Interface IWTextRange
Represents the text in the Word document.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public interface IWTextRange : IParagraphItem, IEntity
Properties
CharacterFormat
Gets the character format(font properties) of the text. Read-only.
Declaration
WCharacterFormat CharacterFormat { get; }
Property Value
Type |
---|
WCharacterFormat |
Text
Gets or sets the text.
Declaration
string Text { get; set; }
Property Value
Type |
---|
System.String |
Methods
ApplyCharacterFormat(WCharacterFormat)
Applies the specified character format to the text.
Declaration
void ApplyCharacterFormat(WCharacterFormat charFormat)
Parameters
Type | Name | Description |
---|---|---|
WCharacterFormat | charFormat | The WCharacterFormat to be applied to the text. |
Examples
The following example illustrates how to add a text to the document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add new text
IWTextRange text = document.LastParagraph.AppendText("Hello world");
//Initialize character format
WCharacterFormat characterformat = new WCharacterFormat(document);
characterformat.Bold = true;
characterformat.Italic = true;
characterformat.TextColor = Color.Blue;
//Apply character format
text.ApplyCharacterFormat(characterformat);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
document.EnsureMinimal()
'Add new text
Dim text As IWTextRange = document.LastParagraph.AppendText("Hello world")
'Initialize character format
Dim characterformat As New WCharacterFormat(document)
characterformat.Bold = True
characterformat.Italic = True
characterformat.TextColor = Color.Blue
'Apply character format
text.ApplyCharacterFormat(characterformat)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub