This is a migrated thread and some comments may be shown as answers.

Documentposition of Span

2 Answers 94 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
JoRoSch
Top achievements
Rank 1
JoRoSch asked on 03 Jul 2013, 11:50 AM
Hi everybody,
how can I retrieve the documentposition of a certain Span (not the current where the caret is in). The background is: I need to move the caret to a specific Span when pushing the FastForward / FastRewind button of a microphone to easily dictat in a RadRichTextBox.

Here is what I have yet:

List<NamedPermissionRangeStart> allPermissionRangeStarts = Document.EnumerateChildrenOfType<NamedPermissionRangeStart>().SkipWhile(a => a.Type != "Text").ToList();
            NamedPermissionRangeStart cur = (NamedPermissionRangeStart)Document.CaretPosition.GetCurrentSpanBox().AssociatedSpan.PreviousSibling;
 
            for (int i = 0; i < allPermissionRangeStarts.Count; i++)
            {
                if (allPermissionRangeStarts[i].InternalKey == cur.InternalKey)
                {
                    Document.CaretPosition.MoveToPosition(((Span)allPermissionRangeStarts[i + 1].NextSibling).?????)
                    break;
                }
            }


I hoped to find something that gives me the DocumentPosition where the "???" are.
Is this approach the right one?

Thanks in advance
Jo

2 Answers, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 05 Jul 2013, 05:33 AM
Hello JoRoSch,
You can use DocumentPosition.MoveToInline(...) methods to navigate document position to any Inline, including Span-s and NamedPermissionRangeStart-s.

Regards,
Boby
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
JoRoSch
Top achievements
Rank 1
answered on 08 Jul 2013, 12:42 PM
thanks for this hint, helped a lot.
Tags
RichTextBox
Asked by
JoRoSch
Top achievements
Rank 1
Answers by
Boby
Telerik team
JoRoSch
Top achievements
Rank 1
Share this question
or