Back to Devexpress

TextArea Class

officefileapi-devexpress-dot-docs-dot-presentation-98e1e13f.md

latest6.8 KB
Original Source

TextArea Class

Allows you to access and manipulate text.

Namespace : DevExpress.Docs.Presentation

Assembly : DevExpress.Docs.Presentation.v25.2.dll

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public class TextArea :
    TextAreaBase
vb
Public Class TextArea
    Inherits TextAreaBase

The following members return TextArea objects:

Remarks

To specify the text area content, add TextParagraph objects to the TextArea.Paragraphs collection. To split a paragraph into runs (spans of text that share the same formatting), add TextRun objects to the TextParagraph.Runs collection.

A new shape’s text area initially contains one default empty paragraph to keep the presentation document valid. This paragraph goes first in the TextArea.Paragraphs collection.

You can also use TextArea.Text, TextParagraph.Text, and TextRun.Text properties to specify text content. Use the “\r\n” character sequence to split the string value into paragraphs or runs.

Example

The following example adds a shape with two paragraphs and configures text settings:

csharp
using DevExpress.Docs.Presentation;

namespace PresentationApiSample;

public class Program {
    public static void Main(string[] _) {
        //...

        Shape shape = new Shape(ShapeType.Rectangle);
        shape.Outline = new OutlineStyle { Fill = new SolidFill(Color.RoyalBlue), Width = 4 };

        TextArea textArea = new TextArea();
        textArea.Paragraphs.Clear(); // Removes the default paragraph.
        TextParagraph paragraph1 = new TextParagraph();
        paragraph1.Runs.Add(new TextRun ("5 "));
        paragraph1.Runs.Add(new TextRun {
            Text = "successful",
            TextProperties = new TextProperties {
                Fill = new SolidFill(Color.Green),
                FontSize = 22,
                UnderlineFill = new SolidFill(Color.Black),
                UnderlineType = TextUnderlineType.HeavyDotDotDash,
                UnderlineStyle = new UnderlineStyle(new OutlineStyle { Fill = new SolidFill(Color.Red), Width = 2 }),

            }
        });
        paragraph1.Runs.Add(new TextRun (" builds"));
        textArea.Paragraphs.Add(paragraph1);

        TextParagraph paragraph2 = new TextParagraph();
        paragraph2.Runs.Add(new TextRun ("2 failed builds"));
        paragraph2.Properties = new ParagraphProperties() {
            SpacingBefore = new TextSpacing(TextSpacingType.Point, 30),
            ListBulletColor = new TextBulletColor(new OfficeColor(Color.Red)),
            ListBullet = new CharListBullet('■'),
            ListBulletSize = new TextBulletSize(TextBulletSizeType.Point, 30)
        };
        textArea.Paragraphs.Add(paragraph2);
        shape.TextArea = textArea;

        shape.X = 30;
        shape.Y = 30;
        shape.Width = 800;
        shape.Height = 400;

        slide.Shapes.Add(shape);
    }
}
vb
Imports DevExpress.Docs.Presentation
Imports System.Drawing

Namespace PresentationApiSample

    Public Class Program
        Public Shared Sub Main(__ As String())
            ' ...
            Dim shape As Shape = New Shape(ShapeType.Rectangle)
            shape.Outline = New OutlineStyle With {
                    .Fill = New SolidFill(Color.RoyalBlue),
                    .Width = 4
                }

            Dim textArea As TextArea = New TextArea()
            textArea.Paragraphs.Clear() ' Removes the default paragraph.
            Dim paragraph1 As TextParagraph = New TextParagraph()
            paragraph1.Runs.Add(New TextRun("5 "))
            paragraph1.Runs.Add(New TextRun With {
                .Text = "successful",
                .TextProperties = New TextProperties With {
                    .Fill = New SolidFill(Color.Green),
                    .FontSize = 22,
                    .UnderlineFill = New SolidFill(Color.Black),
                    .UnderlineType = TextUnderlineType.HeavyDotDotDash,
                    .UnderlineStyle = New UnderlineStyle(New OutlineStyle With {
                            .Fill = New SolidFill(Color.Red),
                            .Width = 2
                        })

                }
            })
            paragraph1.Runs.Add(New TextRun(" builds"))
            textArea.Paragraphs.Add(paragraph1)

            Dim paragraph2 As TextParagraph = New TextParagraph()
            paragraph2.Runs.Add(New TextRun("2 failed builds"))
            paragraph2.Properties = New ParagraphProperties() With {
                .SpacingBefore = New TextSpacing(TextSpacingType.Point, 30),
                .ListBulletColor = New TextBulletColor(New OfficeColor(Color.Red)),
                .ListBullet = New CharListBullet("■"c),
                .ListBulletSize = New TextBulletSize(TextBulletSizeType.Point, 30)
            }
            textArea.Paragraphs.Add(paragraph2)
            shape.TextArea = textArea

            shape.X = 30
            shape.Y = 30
            shape.Width = 800
            shape.Height = 400

            slide.Shapes.Add(shape)
        End Sub
    End Class
End Namespace

Implements

ICloneable

Inheritance

Object PresentationObject TextAreaBase TextArea

See Also

TextArea Members

DevExpress Presentation API Library: Work with Shape Text

DevExpress.Docs.Presentation Namespace