The Text element adds highly customized paragraph content to your reports. The Text element includes several text-specific properties that will make your content stand out no matter what the occasion. Several of these properties can be found in the report graphics section, but there are a few properties that are specific to text:
The Text element also exposes several methods that help you insert all kinds of textual content. A few of these methods are listed below:
The following code will create a single Text element. A pattern is applied to the entire Text element, and two styles are applied to individual content elements.
Create the styles.
In C#:
using Infragistics.Documents.Reports.Report;
using Infragistics.Documents.Reports.Report.Text;
using Infragistics.Documents.Reports.Graphics;
.
.
.
Style style1 = new Style(new Font("Arial", 16), Brushes.White);
Style style2 = new Style(new Font("Verdana", 10), Brushes.Black);
Create the text pattern.
In C#:
TextPattern textPattern = new TextPattern();
textPattern.Margins = new Margins(5, 10);
textPattern.Paddings = new Paddings(5);
textPattern.Interval = 5;
textPattern.Borders = new Borders(new Pen(new Color(0, 0, 0)), 5);
textPattern.Background = new Background(Brushes.LightSteelBlue);
Create the Text element and add content to it.
Use the following text to set the string1
variable:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec imperdiet mattis sem. Nunc ornare elit at justo. In quam nulla, lobortis non, commodo eu, eleifend in, elit. Nulla eleifend. Nulla convallis. Sed eleifend auctor purus. Donec velit diam, congue quis, eleifend et, pretium id, tortor. Nulla semper condimentum justo. Etiam interdum odio ut ligula. Vivamus egestas scelerisque est. Donec accumsan. In est urna, vehicula non, nonummy sed, malesuada nec, purus. Vestibulum erat. Vivamus lacus enim, rhoncus nec, ornare sed, scelerisque varius, felis. Nam eu libero vel massa lobortis accumsan. Vivamus id orci. Sed sed lacus sit amet nibh pretium sollicitudin. Morbi urna.
**In C#:**
```csharp
IText sectionText = section1.AddText();
sectionText.ApplyPattern(textPattern);
string string1 = "Lorem ipsum...";
sectionText.AddContent("Heading 1", style1);
sectionText.AddLineBreak();
sectionText.AddContent(string1, style2);
sectionText.AddLineBreak();
sectionText.AddContent("Heading 2", style1);
sectionText.AddLineBreak();
sectionText.AddContent(string1, style2);
```
View on GitHub