Back to Devexpress

DrawingObject.Offset Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-drawingobject-26ff17b5.md

latest6.6 KB
Original Source

DrawingObject.Offset Property

Gets or sets the absolute position of a shape on the page.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
PointF Offset { get; set; }
vb
Property Offset As PointF

Property Value

TypeDescription
PointF

An object that specifies the horizontal and vertical offsets in measurement units defined by the Document.Unit property.

|

Remarks

Top-Level Shapes

Use the Offset property to specify the absolute position of a floating shape on the page relative to the document elements defined by the Shape.RelativeHorizontalPosition and Shape.RelativeVerticalPosition properties.

Note

The Offset property is in effect when the Shape.HorizontalAlignment and Shape.VerticalAlignment properties are set to None.

The example below creates a rectangle and places it on the page as follows:

  • the absolute horizontal position is two inches to the right of the page;

  • the absolute vertical position is one inch below the page.

  • C#

  • VB.NET

csharp
Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Create a rectangle.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, new SizeF(2.5f, 1.5f));
// Specify the rectangle position on the page.
rectangle.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Page;
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Page;
rectangle.Offset = new PointF(2f, 1f);
vb
Dim document As Document = wordProcessor.Document
' Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Create a rectangle.
Dim rectangle As Shape = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, New SizeF(2.5F, 1.5F))
' Specify the rectangle position on the page.
rectangle.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Page
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Page
rectangle.Offset = New PointF(2F, 1F)

Nested Shapes

Use a nested shape’s Offset property to modify its position relative to the top left corner of a parent object (a shape group or a drawing canvas).

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.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Shapes.cs#L35

csharp
// Specify the offset value.
myPicture.Offset = new System.Drawing.PointF(4.5f, 2.0f);
#endregion #FloatingPictureOffset

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/ShapesActions.cs#L46

csharp
// Specify the offset value.
myPicture.Offset = new System.Drawing.PointF(4.5f, 2.0f);
#endregion #FloatingPictureOffset

word-document-api-examples/CS/CodeExamples/ShapesActions.cs#L65

csharp
// Specify the offset value.
    myPicture.Offset = new System.Drawing.PointF(4.5f, 2.0f);
}

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Shapes.vb#L32

vb
' Specify the offset value.
            myPicture.Offset = New System.Drawing.PointF(4.5F, 2.0F)
#End Region ' #FloatingPictureOffset

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/ShapesActions.vb#L39

vb
' Specify the offset value.
            myPicture.Offset = New System.Drawing.PointF(4.5F, 2.0F)
' #End Region ' #FloatingPictureOffset

word-document-api-examples/VB/CodeExamples/ShapesActions.vb#L57

vb
' Specify the offset value.
    myPicture.Offset = New System.Drawing.PointF(4.5F, 2.0F)
End If

See Also

RelativeHorizontalPosition

RelativeVerticalPosition

OffsetX

OffsetY

DrawingObject Interface

DrawingObject Members

DevExpress.XtraRichEdit.API.Native Namespace