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

ImageProperties.HorizontalOffset Property

Specifies an image’s offset from a horizontal anchor element.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public int HorizontalOffset { get; set; }

#Property Value

Type Description
Int32

The horizontal offset in twips.

#Remarks

Use any of the following properties to define a horizontal position of an image relative to its horizontal anchor element:

HorizontalAlignment
Horizontally aligns an image. If you set this property to a value different from None, the Rich Text Editor sets the HorizontalOffset and HorizontalRelativeOffset properties to 0.
HorizontalOffset
Defines an image’s horizontal offset in twips. If you set this property to a value different from 0, the Rich Text Editor sets the HorizontalRelativeOffset property to 0.
HorizontalRelativeOffset
Defines an image’s horizontal offset in percentage.

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

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;
            @* ... *@
            Image firstImage = await documentAPI.Images.GetAsync(0);
            @* ... *@
            await firstImage.ChangePropertiesAsync(properties => {
                if (firstImage.HorizontalOffset == 0) {
                    properties.HorizontalAlignment = FloatingObjectHorizontalAlignment.None;
                    properties.HorizontalOffset = UnitConverter.CentimetersToTwips(1);
                }
            });
            @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

Use the HorizontalOffset property to get the horizontal offset of the image.

See Also