Back to Devexpress

TextParagraph.Runs Property

officefileapi-devexpress-dot-docs-dot-presentation-dot-textparagraph.md

latest5.3 KB
Original Source

TextParagraph.Runs Property

Obtains the collection of text regions with individual formatting.

Namespace : DevExpress.Docs.Presentation

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

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public TextRunCollection Runs { get; }
vb
Public ReadOnly Property Runs As TextRunCollection

Property Value

TypeDescription
TextRunCollection

A collection of text 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

See Also

TextParagraph Class

TextParagraph Members

DevExpress.Docs.Presentation Namespace