Back to Devexpress

ShapeText Interface

officefileapi-devexpress-dot-spreadsheet-3396dcb0.md

latest3.5 KB
Original Source

ShapeText Interface

Provides access to a shape’s text format settings.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public interface ShapeText
vb
Public Interface ShapeText

The following members return ShapeText objects:

Remarks

Use the Shape.ShapeText property to access the ShapeText object.

Use the ShapeText properties to format the shape text. You can change the text alignment (ShapeText.VerticalAnchor, ShapeText.HorizontalAnchor), orientation (ShapeText.Orientation), margins, etc.

Access a specific text range using the ShapeText.Characters method. Use the ShapeTextRange.Text property to change the range’s content. The ShapeTextRange.Font and ShapeTextRange.ParagraphFormat properties provide access to the range’s font and paragraph options.

Example

csharp
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;
vb
Dim shapeText As ShapeText = shape4.ShapeText

'Create a text range:
Dim range As ShapeTextRange = 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:  
Dim range2 As ShapeTextRange = 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

ShapeText Members

How to: Add Text to a Shape

DevExpress.Spreadsheet Namespace