ShapeText.Characters() Method
Returns a range of all characters in the current shape text string.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Returns
Type | Description |
---|---|
ShapeTextRange | A ShapeTextRange object containing all shape text strings. |
Remarks
Call the Characters method to format a specific text range within the shape text. The Characters property returns a ShapeTextRange object representing a text range. Specify the shape’s text using the RichTextRange.Text property.
You can change the retrieved range’s font settings using the ShapeTextRange.Font property. The ShapeTextRange.ParagraphFormat property provides access to the range’s paragraph properties. When you use the Characters method to insert new text to the range, this text has the same font and paragraph properties as the existing content.
Call the ShapeTextRange.AddBefore or ShapeTextRange.AddAfter method to insert a new text range before of after the retrieved ShapeTextRange object. The ShapeTextRange.GetRuns method returns all text ranges in the shape text.
Call the ShapeTextRange.Delete method to delete the ShapeTextRange object.
Refer to the How to: Add Text to a Shape topic for an example of how to create a shape text.
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;