ShapeTextRange Interface
Represents a text range within a shape.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Related API Members
The following members return ShapeTextRange objects:
Remarks
Call one of the ShapeText.Characters method overloads to retrieve the ShapeTextRange object. You can create a new ShapeTextRange object placed before or after another shape text range using the ShapeTextRange.AddBefore or ShapeTextRange.AddAfter methods.
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 properties. Call the ShapeTextRange.GetRuns method to retrieve all text runs in a current ShapeTextRange object. The ShapeTextRange.GetParagraphs method returns all paragraphs in a ShapeTextRange object.
A ShapeTextRange object can contain ranges with different font and paragraph properties. Use IsMixed… properties to determine whether the current ShapeTextRange object has different paragraph or font properties applied.
Call the ShapeTextRange.Delete method to delete the ShapeTextRange object.
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;