Skip to main content
Row

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ShapeText.HorizontalAnchor Property

Specifies the horizontal alignment of a shape text.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

ShapeTextHorizontalAnchorType HorizontalAnchor { get; set; }

#Property Value

Type Description
ShapeTextHorizontalAnchorType

One of the ShapeTextHorizontalAnchorType enumeration values indicating the text’s horizontal alignment.

Available values:

Name Description
None

No horizontal alignment is specified.

Center

Specifies a center-aligned shape text.

#Remarks

The HorizontalAnchor property allows you specify the text alignment within a shape. Use the ShapeText.VerticalAnchor property to define the shape text’s vertical alignment.

Specify the ShapeTextParagraphFormat options to define the alignment of a specific shape text’s part. Use the ShapeTextRange.ParagraphFormat property to access these options.

#Example

ShapeText shapeText = shape4.ShapeText;

//Create a text range:
ShapeTextRange range = shapeText.Characters();

//Specify the shape's text 
range.Text = "Shape ";

//Set font properties:
range.Font.Bold = true;
range.Font.Color = Color.YellowGreen;

//Add new text range after the existing text
//And specify the font parameters:         
ShapeTextRange range2 = range.AddAfter("Text");
range2.Font.Italic = true;
range2.Font.Name = "Arial";
range2.Font.Color = Color.BurlyWood;

//Define the text's vertical and horizontal alignment:
shapeText.VerticalAnchor = ShapeTextVerticalAnchorType.Center;
shapeText.HorizontalAnchor = ShapeTextHorizontalAnchorType.Center;
See Also