If there is an empty cell with a permission range and you go to it by pressing the Tab key from the previous cell and then start typing it removes the annotation range. If the cell with the permission range is not empty and the same technique is used there is an InvalidOperationException thrown with the message: "Selection contains uneditable ranges".
Here is a workaround:
this.radRichTextBox.CommandExecuted += this.RadRichTextBox_CommandExecuted;
private void RadRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
if (e.Command is TabForwardCommand)
{
DocumentPosition caret = this.radRichTextBox.Document.CaretPosition;
if (caret.IsPositionInsideTable)
{
DocumentSelection selection = this.radRichTextBox.Document.Selection;
DocumentPosition start = selection.Ranges.First.StartPosition;
DocumentPosition end = selection.Ranges.Last.EndPosition;
Inline currentInline = start.GetCurrentInline();
if (currentInline is PermissionRangeStart)
{
start.MoveToNext();
}
Inline previousInline = end.GetPreviousInline();
if (previousInline is PermissionRangeEnd)
{
end.MoveToPrevious();
}
this.radRichTextBox.Document.Selection.SetSelectionStart(start);
this.radRichTextBox.Document.Selection.AddSelectionEnd(end);
}
}
}
First, you need to subscribe to the CommandExecuted event. Then change the selection after a TabForwardCommand to exclude the PermissionRangeStart and PermissionRangeEnd elements. Your workaround also works, so there is no need to change it.