Back to Devexpress

Shape.RelativeVerticalPosition Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-shape-89c05378.md

latest12.3 KB
Original Source

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
ShapeRelativeVerticalPosition RelativeVerticalPosition { get; set; }
vb
Property RelativeVerticalPosition As ShapeRelativeVerticalPosition

Property Value

TypeDescription
ShapeRelativeVerticalPosition

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

|

Available values:

NameDescription
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

AlignmentSpecify the alignment typeRelative to
HorizontalShape.HorizontalAlignmentShape.RelativeHorizontalPosition
VerticalShape.VerticalAlignmentShape.RelativeVerticalPosition

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

csharp
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;
vb
Dim document As Document = wordProcessor.Document
' Create a rectangle.
Dim rectangle As Shape = 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

PositionDefine the offsetRelative to
HorizontalShape.OffsetXShape.RelativeHorizontalPosition
VerticalShape.OffsetYShape.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.

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

Specify the Relative Position

PositionDefine the offset (in percentage)Relative to
HorizontalShape.OffsetXRelativeShape.RelativeHorizontalPosition
VerticalShape.OffsetYRelativeShape.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.

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

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

csharp
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin;
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin;
// Specify the offset value.

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

csharp
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin;
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin;
// Specify the offset value.

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

csharp
// The picture's vertical position is relative to the top margin.
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin;

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

vb
myPicture.RelativeHorizontalPosition = DevExpress.XtraRichEdit.API.Native.ShapeRelativeHorizontalPosition.LeftMargin
myPicture.RelativeVerticalPosition = DevExpress.XtraRichEdit.API.Native.ShapeRelativeVerticalPosition.TopMargin
' Specify the offset value.

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

vb
myPicture.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.LeftMargin
myPicture.RelativeVerticalPosition = ShapeRelativeVerticalPosition.TopMargin
' Specify the offset value.

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

vb
' The picture's vertical position is relative to the top margin.
myPicture.RelativeVerticalPosition = DevExpress.XtraRichEdit.API.Native.ShapeRelativeVerticalPosition.TopMargin
' Specify the offset value.

See Also

VerticalAlignment

Offset

OffsetRelative

Shape Interface

Shape Members

DevExpress.XtraRichEdit.API.Native Namespace