Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Section.Margins Property

Returns the section’s page margins.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public IMargins Margins { get; }

#Property Value

Type Description
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.

Section Margins

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