New to Telerik UI for WinFormsStart a free 30-day trial

Setting Default Cell Content Alignment in RichTextEditor Programmatically

Updated on Mar 16, 2026
Product VersionProductAuthor
2026.1.210RadRichTextEditor for WinFormsDinko Krastev

Description

In this KB article, we will demonstrate how to set text alignment to left and centered programmatically.

Solution

To set all table cell content alignment to left and centered:

  1. Retrieve the table from the document using EnumerateChildrenOfType<Table>().
  2. Clear the current selection.
  3. Set the selection to cover the entire table.
  4. Use the RadDocumentEditor to apply the alignment changes.
  5. Clear the selection after applying the alignment.

Here is the sample code:

C#
var tables = richTextEditor.Document.EnumerateChildrenOfType<Table>();
var table = tables.FirstOrDefault();

richTextEditor.Document.Selection.Clear();

var start = new DocumentPosition(richTextEditor.Document);
start.MoveToDocumentElementStart(table);
richTextEditor.Document.Selection.AddSelectionStart(start);

var end = new DocumentPosition(richTextEditor.Document);
end.MoveToDocumentElementEnd(table);
richTextEditor.Document.Selection.AddSelectionEnd(end);

RadDocumentEditor editor = new RadDocumentEditor(richTextEditor.Document);
editor.ChangeTableCellContentAlignment(RadTextAlignment.Left, Telerik.WinForms.Documents.Layout.RadVerticalAlignment.Center);
richTextEditor.Document.Selection.Clear();

See Also

In this article
DescriptionSolutionSee Also
Not finding the help you need?
Contact Support