Unplanned
Last Updated: 06 May 2016 14:13 by ADMIN
ADMIN
Dimitar
Created on: 04 Mar 2016 12:50
Category: RichTextEditor
Type: Bug Report
0
FIX. RadRichTextEditor - NullRefenceException when one tries to remove invalid bookmark.
To reproduce:
- Copy the content from the attached document - do not copy the last row.
- Remove the bookmarks like this:

bookmarks = radRichTextEditor1.Document.GetAllBookmarks().ToArray();
foreach (BookmarkRangeStart item in bookmarks)
{
    radRichTextEditor1.Document.GoToBookmark(item);
    radRichTextEditor1.DocumentEditor.DeleteBookmark(item);
   
}

Workaround:
                    var invalidStarts = this.radRichTextBox.Document
                    .EnumerateChildrenOfType<BookmarkRangeStart>()
                    .Where(start => start.End == null)
                    .ToList();

                    foreach (var invalidStart in invalidStarts)
                    {
                        invalidStart.Parent.Children.Remove(invalidStart);
                    } 
Note that when this workaround is used the document history will be deleted as well, which means that the undo operation will no longer hold information for previous operations
0 comments