TextSpan.Text Property
Gets textual representation of the span content.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v21.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public string Text { get; }
Property Value
Type | Description |
---|---|
String | The text. |
Remarks
The Text property returns the span content converted to plain text. In this case, images and shape objects are returned as the object replacement character () and fields are returned in their full notation (for instance, "{DATE}20/5/2021>"
).
The following example shows how you can use the Text property to find and delete words.
<DxRichEdit @ref="richEdit" />
@code {
DxRichEdit richEdit;
Document documentAPI;
@* ... *@
/* Surround the code that contains an asynchronous operation with a try-catch block to handle
the OperationCanceledException. This exception is thrown when an asynchronous operation is cancelled. */
try {
documentAPI = richEdit.DocumentAPI;
for (int i = 2; i < 6; i++) {
await documentAPI.Paragraphs.CreateAsync();
await documentAPI.AddTextAsync("New Paragraph " + i.ToString());
}
IReadOnlyList<Paragraph> paragraphs = await documentAPI.Paragraphs.GetAllAsync();
Paragraph curParagraph;
int position;
for (int i = 0; i < paragraphs.Count; i++) {
curParagraph = await documentAPI.Paragraphs.GetAsync(i);
TextSpan currentCharacters = await documentAPI.GetTextSpanAsync(curParagraph.Interval);
position = curParagraph.Interval.Start + currentCharacters.Text.IndexOf("New ");
await documentAPI.RemoveAsync(position, 4);
}
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
See Also