$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
RichTextBox Control for Windows Forms
Edit rich text content with text formatting options, mail-merge, table, and floating objects, etc.
Home > WinForms UI Controls > User Manual > RichTextBox Span Element in C#

Customize Span for KetticDocument in RichTextBox in C#.NET

The Span C# class of the KetticRichTextBox is used to show the formatted text. This span class is an inline object and can only be used in the context underneath the Paragraph C# class. The Span elements will be placed one after another and will wrap the text within the span to the next line when the space of current line is insufficient. The Span C# class provides various properties for the users to customize the layout of the elements. In this article, we will work through the process of applying spans, adding text to a span, as well as customizing spans.

Apply Spans Element to Context of Paragraph in KetticDocument

KetticRichTextBox control applies the Spans only into the context of a Paragraph element in KetticDocument. The users can add the spans to the paragraph by using the collection of Inlines as the C# code below.

Section section = new Section();
Paragraph paragraph = new Paragraph();
Span span = new Span("Span");
paragraph.Inlines.Add(span);
section.Blocks.Add(paragraph);
this.ketticRichTextBox1.Document.Sections.Add(section);

Add Text to a Span in Context of a Paragraph

KetticRichTextBox control provides the Text property for the users to add text inside a Span. The C# code below shows how to achieve this.

Span mySpan = new Span();
mySpan.Text = "Text";

Properties for Customizing Spans in KetticDocument

The Span C# class contains a variety of properties for the users to customize the layout of the elements placed under the spans in KetticDocument, such as
  • BaselineAlignment, this property is used to set the text in the span to be Baseline, Subscript or Superscript.
  • FontSize, this property is used to adjust the font size of the text within the Span.
  • ForeColor, this property is used to determine the foreground color of the text in a span.
  • Strikethrough, this property is able to set the text to be stroke through
  • FontFamily, this property is used to set the font name of the text in span
  • FontStyle, this property is able to set the text in a span to be bold, italic or normal.
  • HighlightColor, this property is used to determine the background color of the text in a span.
  • UnderlineType, this property is used to underline the text in a span
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls