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

Paragraph

The paragraph class allows you to separate the content into paragraphs. It is responsible for displaying inline elements such as Span, HyperlinkRangeStart and End, InlineImage etc. You are also able to configure the appearance of the paragraph by modifying its parameters.

This topic will explain you how to:

Use Paragraphs

The Paragraph can be used only in the context of a Section or a TableCell element. The section exposes a collection of Blocks, to which the paragraphs can be added.


Section section = new Section();
Paragraph paragraph = new Paragraph();          
section.Blocks.Add(paragraph);
RadDocument document = new RadDocument();
document.Sections.Add(section);

this.radRichTextEditor1.Document = document;

Dim section As New Section()
Dim paragraph As New Paragraph()    
section.Blocks.Add(paragraph)
Dim document As New RadDocument()
document.Sections.Add(section)
Me.radRichTextEditor1.Document = document

Add inline elements to a Paragraph

To add inline elements such as Span, HyperlinkRangeStart and End, or InlineImage you have to use the Inlines collection of the Paragraph.


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);
RadDocument document = new RadDocument();
document.Sections.Add(section);

this.radRichTextEditor1.Document = document;

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)
Dim document As New RadDocument()
document.Sections.Add(section)
Me.radRichTextEditor1.Document = document

Customize the Paragraph

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

  • FontSize - represents the font size of the text inside the Paragraph. If not explicitly set to its child elements, they inherit its value.

  • LineSpacing - specifies the value for the space between the lines.

  • LineSpacingType - specifies the type of spacing:

    • AtLeast - the space between the lines should be equal or greater than the value of the LineSpacing property.

    • Auto - the space between the lines is determined automatically.

    • Exact - the space between the lines should be equal to the value of the LineSpacing property.

  • LeftIndent - represents the size of the indent to the left size of the Paragraph. The indent gets applied together with the respective margins to the layout.

  • RightIndent - represents the size of the indent to the right size of the Paragraph. The indent gets applied together with the respective margins to the layout.

  • SpacingAfter - represents the size of the empty space after the Paragraph.

  • SpacingBefore - represents the size of the empty space before the Paragraph.

  • TextAlignment - represents the alignment of the text inside the Paragraph.

See Also

In this article