New to Telerik UI for WinForms? Download free 30-day trial


The Span class represents an inline object that allows you to display formatted text. The Spans can only be used in the context of a Paragraph class. As the spans are inline elements they get placed one after another and the text inside them gets wrapped to the next line if the space is insufficient.

This topic demonstrates how to:

Use Spans

The Spans__can be used only in the context of the Paragraph element. The __Paragraph exposes a collection of Inlines, to which the spans can be added.

Section section = new Section();
Paragraph paragraph = new Paragraph();
Span span = new Span("Span declared in code-behind");

Dim section As New Section()
Dim paragraph As New Paragraph()
Dim span As New Span("Span declared in code-behind")

Add Text to a Span

To specify the text in the Span you can use its Text property.

Span mySpan = new Span();
mySpan.Text = "Thank you for choosing Telerik RadRichTextBox!";

Dim mySpan As New Span()
mySpan.Text = "Thank you for choosing Telerik RadRichTextBox!"

The Text property of Span cannot be set to an empty string, as Spans that do not contain any text are considered invalid. If you add an empty Span in the document programmatically, an exception will be thrown.

Customize a Span

The Span exposes several properties that allow you to customize the layout of the elements placed underneath it. Here is a list of them:

  • BaselineAlignment - indicates whether the text is Baseline, Subscript or Superscript.

  • FontFamily - represents the name of the text's font.

  • FontSize - represent the size of the text.

  • FontStyle - indicates whether the text should have its style set to bold, italic or to normal.

  • ForeColor - represents the foreground color for the text.

  • HighlightColor - represents the background color for the text.

  • Strikethrough - indicates whether the text should be stroke through.

  • UnderlineType - indicates whether the text should be underlined.

In this article