In MS Word, the users can change the alignment of a table using the buttons related to Paragraph alignment. To do that, the whole table must be selected.
In RadRichTextBox, selecting a Table and pressing one of the buttons, let say for Right alignment, leads to aligning the content of the table and not the table itself.
Workaround:
private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is ChangeTextAlignmentCommand &&
this.radRichTextBox.Document.Selection.Ranges.Count == 1 &&
this.radRichTextBox.Document.Selection.Ranges.First.RangeType == SelectionRangeType.Table &&
e.CommandParameter.ToString() != "Justify")
{
e.Cancel = true;
RadDocumentEditor editor = new RadDocumentEditor(this.radRichTextBox.Document);
RadHorizontalAlignment newAlignment = (RadHorizontalAlignment) Enum.Parse(typeof(RadHorizontalAlignment), e.CommandParameter.ToString());
editor.ChangeTableHorizontalAlignment(newAlignment);
}
}
NOTE: With this approach, the toggle buttons in the UI are not updated properly and this should be additionally handled.