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

GetAllBookmarks() is empty

3 Answers 77 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Joe Buckle
Top achievements
Rank 1
Joe Buckle asked on 05 Jun 2011, 01:21 PM
Good day,

I'm trying to get all the bookmarks in a RadDocument, but GetAllBookmarks() returns an empty list. But when I try to set

RadRichTextBox.Document.ShowBookmarks to true, the bookmarks are there. Why is this so?

Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 06 Jun 2011, 12:44 PM
Hello Joe Buckle,

In order to get all Bookmarks, the document has to be measured and arranged. If you are invoking the GetAllBookmarks method before showing the document in a RadRichTextBox in the visual tree, the list will be empty. When the document is shown on screen, it is automatically measured and arranged, but if you would like to get all bookmarks before that, you have two options:
  1. Measure and arrange the document explicitly:
    private IEnumerable<BookmarkRangeStart> GetAllBookmarks(RadDocument document)
    {
       document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
       document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
       return document.GetAllBookmarks();
    }
  2. Use another method to get the bookmarks, which doesn't require a measured document, but is slower:
    private IEnumerable<BookmarkRangeStart> GetAllBookmarks(RadDocument document)
    {
      return document.EnumerateChildrenOfType<BookmarkRangeStart>();
    }
Please note that in the next version, the document will be measured automatically upon invocation of GetAllBookmarks (and methods with similar requirements) if it hasn't been previously.

Greetings,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Buckle
Top achievements
Rank 1
answered on 06 Jun 2011, 01:13 PM
Thank you very much. But how do I set the content of the bookmark for each option?
0
Iva Toteva
Telerik team
answered on 09 Jun 2011, 12:35 PM
Hi Joe Buckle,

I am not quite sure I understand your question. Can you elaborate a little on your scenario, for example:
  • Do you want to delete the bookmark and insert text in its place?
  • Should the bookmarks be deleted, or you still wish to be able to navigate to them?
  • Are you doing this before showing the document in the editor or after it is loaded?
There are some differences in the implementation depending on these factors and if you describe your needs in more detail, we would be able to send you a more useful example.

 All the best,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Joe Buckle
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Joe Buckle
Top achievements
Rank 1
Share this question
or