I have a hard time finding a sollution to delete paragraph from open document. Code below crashes on aither delSection.Blocks.Remove(delParagraph); or later on radRichTextBox.UpdateEditorLayout(); after remove vas called. The error is: "inline does not belong to this document.". This seems to happen randomly. Sometimes everything passes without an error. I cant fine a way to get this working on regular basis.
Also tried a different approach found on this forum, that was suggested by admin. It was that I use selection to select paragraph to remove and the call
radRichTextBox.Delete(false); witch deletes selected content. But the problem is that I have to remove a ReadOnlyRange. So this approach does not fit.
01.private void DeleteTopicFromDoc(string tag)02.{03. Section delSection = null;04. Block delParagraph = null;05. 06. foreach (Section section in radRichTextBox.Document.Sections)07. {08. foreach (var block in section.Blocks)09. {10. var paragraph = block as Paragraph;11. if (paragraph != null)12. {13. string topicTag = string.Format("topic_{0}", tag);14. if (paragraph.Tag == topicTag)15. {16. delSection = section;17. delParagraph = block;18. break;19. }20. }21. }22. if (delParagraph != null) break;23. }24. 25. if (delParagraph != null)26. {27. delSection.Blocks.Remove(delParagraph);28. }29.}Also tried a different approach found on this forum, that was suggested by admin. It was that I use selection to select paragraph to remove and the call
radRichTextBox.Delete(false); witch deletes selected content. But the problem is that I have to remove a ReadOnlyRange. So this approach does not fit.