title | page_title | description | slug | tags | published | position |
---|---|---|---|---|---|---|
Span |
Span |
Check our "Span" documentation article for the RadRichTextBox {{ site.framework_name }} control. |
radrichtextbox-features-document-elements-span |
span |
true |
4 |
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 will explain you how to:
The Spans can be used only in the context of the [Paragraph]({%slug radrichtextbox-features-document-elements-paragraph%}) element. The Paragraph exposes a collection of Inlines, to which the spans can be added. This can also be done directly in XAML.
{{region radrichtextbox-features-document-elements-span_0}} <telerik:RadRichTextBox x:Name="radRichTextBox"> telerik:RadDocument telerik:Section telerik:Paragraph <telerik:Span Text="Span declared in XAML" /> </telerik:Paragraph> </telerik:Section> </telerik:RadDocument> </telerik:RadRichTextBox> {{endregion}}
{{region radrichtextbox-features-document-elements-span_1}} Section section = new Section(); Paragraph paragraph = new Paragraph(); Span span = new Span("Span declared in code-behind"); paragraph.Inlines.Add( span ); section.Blocks.Add( paragraph ); this.radRichTextBox.Document.Sections.Add( section ); {{endregion}}
{{region radrichtextbox-features-document-elements-span_2}} Dim section As New Section() Dim paragraph As New Paragraph() Dim span As New Span("Span declared in code-behind") paragraph.Inlines.Add(span) section.Blocks.Add(paragraph) Me.radRichTextBox.Document.Sections.Add(section) {{endregion}}
To specify the text in the Span you can use its Text property.
{{region radrichtextbox-features-document-elements-span_3}} <telerik:Span Text="Thank you for choosing Telerik RadRichTextBox!" /> {{endregion}}
{{region radrichtextbox-features-document-elements-span_4}} Span span = new Span(); span.Text = "Thank you for choosing Telerik RadRichTextBox!"; {{endregion}}
{{region radrichtextbox-features-document-elements-span_5}} Dim span As New Span() span.Text = "Thank you for choosing Telerik RadRichTextBox!" {{endregion}}
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 italic or to normal.
-
FontWeight - represents the value for the text's weight.
-
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.
-
UnderlineDecoration - indicates whether the text should be underlined.
-
[Elements Hierarchy]({%slug radrichtextbox-features-document-elements-hierarchy%})
-
[RadDocument]({%slug radrichtextbox-features-document-elements-raddocument%})
-
[Section]({%slug radrichtextbox-features-document-elements-section%})
-
[Paragraph]({%slug radrichtextbox-features-document-elements-paragraph%})
-
[Hyperlink]({%slug radrichtextbox-features-document-elements-hyperlink%})
-
[InlineImage]({%slug radrichtextbox-features-document-elements-inlineimage%})