Section.GetHeaderAsync(HeaderFooterType, Boolean) Method
Returns a sub-document that is the section’s header.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v21.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public ValueTask<SubDocument> GetHeaderAsync(
HeaderFooterType type = HeaderFooterType.Odd,
bool createIfNotExist = false
)
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
type | HeaderFooterType | 1 | The type of header to be returned. |
createIfNotExist | Boolean | False | true to create a header if it does not exist; false to not create a header. |
Returns
Type | Description |
---|---|
ValueTask<SubDocument> | A structure that stores an awaitable result of an asynchronous operation. The awaitable result is a sub-document object. |
Remarks
A main sub-document consists of at least one logical section. Each section can have its own header of the following types: first, primary, odd, and even.
Call the GetHeaderAsync method to get a sub-document that is the section header. Use the type parameter to specify the type of the header to return. If the section has no header of the specified type, you can set createIfNotExist to true
to create the new header.
<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;
@* ... *@
Section firstSection = await documentAPI.Sections.GetAsync(0);
var header = await firstSection.GetHeaderAsync(HeaderFooterType.Primary, true);
await header.AddTextAsync("Developer Express Inc.");
@* ... *@
var hParagraph = await header.Paragraphs.GetAsync(0);
await hParagraph.ChangePropertiesAsync(properties => {
properties.Alignment = ParagraphAlignment.Right;
});
await firstsection.ChangePropertiesAsync(properties => {
properties.HeaderOffset = 700;
});
@* ... *@
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}