Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

Shape.RelativeVerticalPosition Property

Gets or sets the element to which the shape’s vertical position is relative.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

ShapeRelativeVerticalPosition RelativeVerticalPosition { get; set; }

Property Value

Type Description
ShapeRelativeVerticalPosition

Defines the element relative to which the shape is positioned vertically.

Remarks

Use one of the following methods to specify the position of a floating shape or picture in a document.

Align a Shape Horizontally and Vertically

Alignment Specify the alignment type Relative to
Horizontal Shape.HorizontalAlignment Shape.RelativeHorizontalPosition
Vertical Shape.VerticalAlignment Shape.RelativeVerticalPosition

The following example displays a rectangle in the center of the page below the top margin:

Document document = wordProcessor.Document;
// Create a rectangle.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, new SizeF(500, 300));
// Align the rectangle horizontally and vertically.
rectangle.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Page;
rectangle.HorizontalAlignment = ShapeHorizontalAlignment.Center;
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Margin;
rectangle.VerticalAlignment = ShapeVerticalAlignment.Top;

Specify the Absolute Position

Position Define the offset Relative to
Horizontal Shape.OffsetX Shape.RelativeHorizontalPosition
Vertical Shape.OffsetY Shape.RelativeVerticalPosition

The Shape.Offset property specifies both the horizontal and vertical positions.

Note

The Offset properties are 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.

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.OffsetX = 2;
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Page;
rectangle.OffsetY = 1;

Specify the Relative Position

Position Define the offset (in percentage) Relative to
Horizontal Shape.OffsetXRelative Shape.RelativeHorizontalPosition
Vertical Shape.OffsetYRelative Shape.RelativeVerticalPosition

The Shape.OffsetRelative property specifies both the horizontal and vertical relative positions.

Note

The OffsetRelative properties are 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 horizontal offset is equal to 20% of the page width,

  • the vertical offset is equal to 10% of the page height.

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.OffsetXRelative = 0.2f;
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Page;
rectangle.OffsetYRelative = 0.1f;

The following code snippets (auto-collected from DevExpress Examples) contain references to the RelativeVerticalPosition 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.

See Also