Skip to main content

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.v23.2.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

ShapeRelativeVerticalPosition RelativeVerticalPosition { get; set; }

Property Value

Type Description
ShapeRelativeVerticalPosition

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

Available values:

Name Description
Page

The shape’s position is relative to the page.

Line

The shape’s position is relative to the line that contains the shape’s anchor.

Paragraph

The shape’s position is relative to the paragraph that contains the shape’s anchor.

Margin

The shape’s position is relative to page margins.

TopMargin

The shape’s position is relative to the top margin.

BottomMargin

The shape’s position is relative to the bottom margin.

InsideMargin

The shape’s position is relative to the inside margin (i.e., the top margin for odd pages, and the bottom margin for even pages).

The Rich Text Editor positions the shape relative to the top margin for both odd and even pages.

OutsideMargin

The shape’s position is relative to the outside margin (i.e., the bottom margin for odd pages, and the top margin for even pages).

The Rich Text Editor positions the shape relative to the bottom margin for both odd and even pages.

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