Class TextObject
Represents the Text object that may display one or several text lines.
Inheritance
Implements
Inherited Members
Namespace: FastReport
Assembly: FastReport.Base.dll
Syntax
public class TextObject : TextObjectBase, IDisposable, IFRSerializable
Remarks
Specify the object's text in the Text property. Text may contain expressions and data items, for example: "Today is [Date]". When report is running, all expressions are calculated and replaced with actual values, so the text would be "Today is 01.01.2008".
The symbols used to find expressions in a text are set in the Brackets property. You also may disable expressions using the AllowExpressions property.
To format an expression value, use the FastReport.Format property.
Constructors
TextObject()
Initializes a new instance of the TextObject class with default settings.
Declaration
public TextObject()
Properties
Angle
Gets or sets the text angle, in degrees.
Declaration
public int Angle { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
AutoShrink
Gets or sets a value that indicates whether the font size should shrink to display the longest text line without word wrap.
Declaration
public AutoShrinkMode AutoShrink { get; set; }
Property Value
Type | Description |
---|---|
AutoShrinkMode |
Remarks
To limit the minimum size, use the AutoShrinkMinSize property.
AutoShrinkMinSize
Gets or sets the minimum size of font (or minimum width ratio) if the AutoShrink mode is on.
Declaration
public float AutoShrinkMinSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
This property determines the minimum font size (in case the AutoShrink property is set to FontSize), or the minimum font width ratio (if AutoShrink is set to FontWidth).
The default value is 0, that means no limits.
AutoWidth
Gets or sets a value that determines if the text object should handle its width automatically.
Declaration
public bool AutoWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Clip
Gets or sets a value that indicates if text should be clipped inside the object's bounds.
Declaration
public bool Clip { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
FirstTabOffset
Gets or sets the offset of the first TAB symbol. Negative value will not affect this property.
Declaration
public float FirstTabOffset { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Font
Gets or sets the font settings for this object.
Declaration
public Font Font { get; set; }
Property Value
Type | Description |
---|---|
Font |
FontWidthRatio
Gets or sets the width ratio of the font.
Declaration
public float FontWidthRatio { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Default value is 1. To make a font wider, set a value grether than 1; to make a font narrower, set a value less than 1.
ForceJustify
Forces justify for the last text line.
Declaration
public bool ForceJustify { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
HasHtmlTags
Indicates handling html tags in the text.
Declaration
public bool HasHtmlTags { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
To set the value use the TextRenderer property.
Highlight
Gets the collection of conditional highlight attributes.
Declaration
public ConditionCollection Highlight { get; }
Property Value
Type | Description |
---|---|
ConditionCollection |
Remarks
Conditional highlight is used to change the visual appearance of the Text object depending on some condition(s). For example, you may highlight negative values displayed by the Text object with red color. To do this, add the highlight condition:
TextObject text1;
HighlightCondition highlight = new HighlightCondition();
highlight.Expression = "Value < 0";
highlight.Fill = new SolidFill(Color.Red);
highlight.ApplyFill = true;
text1.Highlight.Add(highlight);
HorzAlign
Gets or sets the horizontal alignment of a text in the TextObject object.
Declaration
public HorzAlign HorzAlign { get; set; }
Property Value
Type | Description |
---|---|
HorzAlign |
HtmlTags
Allows handling html tags in the text.
Declaration
[Obsolete("This method is deprecated please use TextRenderer")]
public bool HtmlTags { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The following html tags can be used in the object's text: <b>, <i>, <u>, <strike>, <sub>, <sup>, </b>, </i>, </u>, </strike>, </sub>, </sup>, <font color=&...&>, </font>. Font size cannot be changed due to limitations in the rendering engine.
InlineImageCache
Cache for inline images
Declaration
public InlineImageCache InlineImageCache { get; }
Property Value
Type | Description |
---|---|
InlineImageCache |
LineHeight
Gets or sets the height of single text line, in pixels.
Declaration
public float LineHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
MergeMode
Gets or sets a value indicating whether the text should be merged with other nearby text objects.
Declaration
public MergeMode MergeMode { get; set; }
Property Value
Type | Description |
---|---|
MergeMode |
ParagraphFormat
Gets or sets a paragraph format for a new html rendering type, not for others rendering
Declaration
public ParagraphFormat ParagraphFormat { get; set; }
Property Value
Type | Description |
---|---|
ParagraphFormat |
ParagraphOffset
Gets or sets the paragraph offset, in pixels. For HtmlParagraph use ParagraphFormat.FirstLineIndent.
Declaration
public float ParagraphOffset { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
RightToLeft
Gets or sets a value that indicates whether the component should draw right-to-left for RTL languages.
Declaration
public bool RightToLeft { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
TabPositions
Gets or sets a collection of TAB symbol positions, in pixels. Negative values will not affect this property.
Declaration
public FloatCollection TabPositions { get; set; }
Property Value
Type | Description |
---|---|
FloatCollection |
Remarks
Use collection methods to add or remove TAB positions.
TabWidth
Gets or sets the width of TAB symbol, in pixels. Negative values will not affect this property.
Declaration
public float TabWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
TextColor
Gets or sets the text color in a simple manner.
Declaration
public Color TextColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
Remarks
This property can be used in a report script to change the text color of the object. It is equivalent to:
textObject1.TextFill = new SolidFill(color);
TextFill
Gets or sets the fill color used to draw a text.
Declaration
public FillBase TextFill { get; set; }
Property Value
Type | Description |
---|---|
FillBase |
Remarks
Default fill is SolidFill. You may specify other fill types, for example:
text1.TextFill = new HatchFill(Color.Black, Color.White, HatchStyle.Cross);
Use the TextColor property to set the solid text color.
TextOutline
Gets or sets the text outline.
Declaration
public TextOutline TextOutline { get; set; }
Property Value
Type | Description |
---|---|
TextOutline |
TextRenderType
The type of text render
Declaration
public TextRenderType TextRenderType { get; set; }
Property Value
Type | Description |
---|---|
TextRenderType |
Remarks
The following html tags can be used in the object's text: <b>, <i>, <u>, <strike>, <sub>, <sup>, </b>, </i>, </u>, </strike>, </sub>, </sup>, <font color=&...&>, </font>. Font size cannot be changed due to limitations in the rendering engine.
Trimming
Gets or sets the string trimming options.
Declaration
public StringTrimming Trimming { get; set; }
Property Value
Type | Description |
---|---|
StringTrimming |
Underlines
Gets or sets a value that determines if the text object will underline each text line.
Declaration
public bool Underlines { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
VertAlign
Gets or sets the vertical alignment of a text in the TextObject object.
Declaration
public VertAlign VertAlign { get; set; }
Property Value
Type | Description |
---|---|
VertAlign |
WordWrap
Gets or sets a value that indicates if lines are automatically word-wrapped.
Declaration
public bool WordWrap { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Wysiwyg
Gets or sets a value that indicates if the text object should display its contents similar to the printout.
Declaration
public bool Wysiwyg { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
ApplyStyle(Style)
Declaration
public override void ApplyStyle(Style style)
Parameters
Type | Name | Description |
---|---|---|
Style | style |
Overrides
Assign(Base)
Declaration
public override void Assign(Base source)
Parameters
Type | Name | Description |
---|---|---|
Base | source |
Overrides
Break(BreakableComponent)
Declaration
public override bool Break(BreakableComponent breakTo)
Parameters
Type | Name | Description |
---|---|---|
BreakableComponent | breakTo |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
CalcHeight()
Declaration
public override float CalcHeight()
Returns
Type | Description |
---|---|
System.Single |
Overrides
CalcWidth()
Calculates the object's width.
Declaration
public float CalcWidth()
Returns
Type | Description |
---|---|
System.Single | The width, in pixels. |
Deserialize(FRReader)
Declaration
public override void Deserialize(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader |
Overrides
DeserializeSubItems(FRReader)
Declaration
protected override void DeserializeSubItems(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader |
Overrides
Draw(FRPaintEventArgs)
Declaration
public override void Draw(FRPaintEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
FRPaintEventArgs | e |
Overrides
DrawText(FRPaintEventArgs)
Draws a text.
Declaration
public void DrawText(FRPaintEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
FRPaintEventArgs | e | Paint event data. |
FinalizeComponent()
Declaration
public override void FinalizeComponent()
Overrides
GetData()
Declaration
public override void GetData()
Overrides
GetDataAsync(CancellationToken)
Declaration
public override async Task GetDataAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
GetExpressions()
Declaration
public override string[] GetExpressions()
Returns
Type | Description |
---|---|
System.String[] |
Overrides
GetHtmlTextRenderer(Single, Single)
Returns an instance of html text renderer.
Declaration
public HtmlTextRenderer GetHtmlTextRenderer(float scale, float fontScale)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scale | Scale ratio. |
System.Single | fontScale | Font scale ratio. |
Returns
Type | Description |
---|---|
HtmlTextRenderer | The html text renderer. |
GetStringFormat(GraphicCache, StringFormatFlags)
Returns StringFormat object.
Declaration
public StringFormat GetStringFormat(GraphicCache cache, StringFormatFlags flags)
Parameters
Type | Name | Description |
---|---|---|
GraphicCache | cache | Report graphic cache. |
StringFormatFlags | flags | StringFormat flags. |
Returns
Type | Description |
---|---|
StringFormat | StringFormat object. |
InitializeComponent()
Declaration
public override void InitializeComponent()
Overrides
RestoreState()
Declaration
public override void RestoreState()
Overrides
RestoreStyle()
Declaration
public override void RestoreStyle()
Overrides
SaveState()
Declaration
public override void SaveState()
Overrides
SaveStyle()
Declaration
public override void SaveStyle()
Overrides
Serialize(FRWriter)
Declaration
public override void Serialize(FRWriter writer)
Parameters
Type | Name | Description |
---|---|---|
FRWriter | writer |