SubDocument.AddTextAsync(Int32, String, CancellationToken) Method
In This Article
Inserts the text at the specified position.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
#Declaration
C#
public ValueTask<TextSpan> AddTextAsync(
int position,
string text,
CancellationToken cancellationToken = default(CancellationToken)
)
#Parameters
Name | Type | Description |
---|---|---|
position | Int32 | The position in the sub-document where to insert the text. |
text | String | The text to insert. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellation |
Cancellation |
null | An object that propagates a cancellation notification. |
#Returns
Type | Description |
---|---|
Value |
A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the inserted text span. |
#Remarks
Use the ChangePropertiesAsync(Action<CharacterProperties>, CancellationToken) method to specify character properties of the inserted text.
Razor
<DxRichEdit @ref="richEdit" CssClass="w-100 ch-720"/>
@code {
DxRichEdit richEdit;
async Task InitializeDocument() {
Document documentAPI = richEdit.DocumentAPI;
documentAPI.BeginUpdate();
documentAPI.BeginTransaction();
await CreateTitleParagraph(documentAPI);
await documentAPI.EndTransaction();
documentAPI.EndUpdate();
}
async Task CreateTitleParagraph(Document documentAPI) {
Paragraph titleParagraph = await documentAPI.Paragraphs.CreateAsync(0);
await titleParagraph.ChangePropertiesAsync(properties => { properties.SpacingAfter = 400; });
TextSpan titleParagraphTextSpan = await documentAPI.AddTextAsync(0, "Albert Einstein");
await titleParagraphTextSpan.ChangePropertiesAsync(properties => {
properties.FontName = "Arial";
properties.FontSize = 24;
properties.FontBold = true;
});
}
}
See Also