Class TextBox
Inheritance
System.Object
TextBox
Assembly: IronPPT.dll
Syntax
public class TextBox : Shape, ICloneableElement, IParentElement, IShape, IGraphic, ITextBox, IContentElement, IHasParagraphStyle
When a slide needs a bordered container that holds paragraphs of text, TextBox provides it. It is a shape that carries text, combining a shape's placement and styling with a text container's ability to hold and format multiple paragraphs, so a developer can lay out body copy, captions, and callouts as discrete blocks.
A TextBox is created and added to a slide, then filled through its Add methods. Text content uses AddText (a string or an IText) and AddParagraph; nested graphics use AddShape and the four AddImage overloads (a path, a Stream, an AnyBitmap, or an existing IImage); and AddChild adds raw content elements. The text it holds is read back through the Paragraphs and Texts collection properties, each a List of the matching interface.
Paragraph-level formatting for the whole box is set through Style, an IParagraphStyle that applies spacing and alignment across the box's paragraphs in one place rather than per paragraph. Because TextBox derives from Shape, it also carries the shape members for fill, outline, and geometry, so the same object positions itself on the slide and styles its border. That inheritance is what lets a caption sit in a bordered, filled frame and move as a single unit when the layout changes. Add the paragraphs first, then set Style for shared formatting, and reach for TextBox over loose text whenever the content should live in one movable, styleable frame.
var textBox = new TextBox();
textBox.AddParagraph(paragraph);
textBox.AddText("Caption");
slide.AddShape(textBox);
The add text how-to places text on a slide, the add paragraph example builds the paragraphs a text box holds, and the paragraph style example styles them.
Constructors
TextBox()
Declaration
TextBox(ContentElement[])
Declaration
public TextBox(params ContentElement[] contents)
Parameters
Properties
Paragraphs
Declaration
public List<IParagraph> Paragraphs { get; }
Property Value
| Type |
Description |
| System.Collections.Generic.List<IParagraph> |
|
Style
Declaration
public IParagraphStyle Style { get; set; }
Property Value
Texts
Declaration
public List<IText> Texts { get; }
Property Value
| Type |
Description |
| System.Collections.Generic.List<IText> |
|
Methods
AddChild(IContentElement[])
Declaration
public override void AddChild(params IContentElement[] children)
Parameters
Overrides
AddImage(IImage)
Declaration
public IImage AddImage(IImage image)
Parameters
| Type |
Name |
Description |
| IImage |
image |
|
Returns
AddImage(AnyBitmap)
Declaration
public IImage AddImage(AnyBitmap anyBitmap)
Parameters
| Type |
Name |
Description |
| IronSoftware.Drawing.AnyBitmap |
anyBitmap |
|
Returns
AddImage(Stream)
Declaration
public IImage AddImage(Stream imageStream)
Parameters
| Type |
Name |
Description |
| System.IO.Stream |
imageStream |
|
Returns
AddImage(String)
Declaration
public IImage AddImage(string imagePath)
Parameters
| Type |
Name |
Description |
| System.String |
imagePath |
|
Returns
AddParagraph(IParagraph)
Declaration
public IParagraph AddParagraph(IParagraph paragraph)
Parameters
Returns
AddShape(IShape)
Declaration
public IShape AddShape(IShape shape)
Parameters
| Type |
Name |
Description |
| IShape |
shape |
|
Returns
AddText(IText)
Declaration
public IText AddText(IText text)
Parameters
| Type |
Name |
Description |
| IText |
text |
|
Returns
AddText(String)
Declaration
public IText AddText(string text)
Parameters
| Type |
Name |
Description |
| System.String |
text |
|
Returns
Implements