Back to Devexpress

Section.Margins Property

blazor-devexpress-dot-blazor-dot-richedit-dot-section.md

latest2.5 KB
Original Source

Section.Margins Property

Returns the section’s page margins.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public IMargins Margins { get; }

Property Value

TypeDescription
IMargins

An object that implements the IMargins interface and contains margin settings, in twips.

|

Remarks

The Margins property returns page margins of the current section.

Call the section’s ChangePropertiesAsync(Action<SectionProperties>, CancellationToken) method to change the section margins.

razor
<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 canceled. */
        try {
            documentAPI = richEdit.DocumentAPI;
            var sections = await documentAPI.Sections.GetAllAsync();
            foreach (Section s in sections)
                await s.ChangePropertiesAsync(properties => {
                    if (s.Margins.Left != 700)
                        properties.Margins.Left = 700;
                    if (s.Margins.Right != 700)
                        properties.Margins.Right = 700;
                    if (s.Margins.Top != 567)
                        properties.Margins.Top = 567;
                    if (s.Margins.Bottom != 567)
                        properties.Margins.Bottom = 567;
                });
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

Use methods of the UnitConverter class to convert centimeters, inches, pixels, or points to twips.

See Also

Section Class

Section Members

DevExpress.Blazor.RichEdit Namespace