Shape.Offset Property
Gets or sets the shape position relative to a certain element of the document layout.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v19.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
PointF | A PointF object specifying the offset of the shape measured in current units. |
Remarks
The position of a shape is measured from the upper-left corner of the shape’s bounding box. The Shape.RelativeHorizontalPosition and the Shape.RelativeVerticalPosition properties define elements of the document layout from which an offset is measured. If horizontal or vertical alignment is specified (the Shape.HorizontalAlignment or the Shape.VerticalAlignment properties are set to values other than None), the Offset value is disregarded.
This example moves a floating object to a position where its upper left corner is located at 4.5 cm to the right of the left margin and 2 cm below the top margin.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/word-processing-document-api-examples-t418535
Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
document.Unit = DevExpress.Office.DocumentUnit.Centimeter;
Shape myPicture = document.Shapes[1];
// Clear the qualitative positioning to allow positioning by specifying the numerical offset.
myPicture.HorizontalAlignment = ShapeHorizontalAlignment.None;
myPicture.VerticalAlignment = ShapeVerticalAlignment.None;
// Specify the reference item for positioning.
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin;
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin;
// Specify the offset value.
myPicture.Offset = new System.Drawing.PointF(4.5f, 2.0f);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Offset property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.