Current filter:
                                You should refresh the page.
                                Support Center
                                  • dear support,
                                    again a question where I am not sure if its my stupidity or if I am missing something.

                                    I have an xtrarichedit document in which I want to replace the contents of a bookmark.
                                    I follow the codeexample you give under:

                                    It works ok for the first bookmark. but not if there is more then one bookmark in the document.
                                    The old text is not replaced correctly by the new text only fragments of the new text appear.

                                    The createRange method does not do what I want it to do.

                                    My source follows with comments:

                                    string newText = "newtext";
                                    int length = newText.Length;
                                    DocumentPosition docPos = footnotes.Document.Bookmarks[bmIndex].Range.End;
                                    // docPos has now value of 16 which is correct;
                                    footnotes.Document.InsertText(docPos, newText);

                                       DocumentRange range = footnotes.Document.CreateRange(
                                       footnotes.Document.Bookmarks[bmIndex].Range.End.ToInt() - length);

                                    once the program has executed the above line there is an error:

                                    // footnotes.Document.Bookmarks[bmIndex].Range.Start = 5 : correct
                                    // footnotes.Document.Bookmarks[bmIndex].Range.End = 16 : correct
                                    // length = 7 : correct

                                    // range.End = 14 : wrong! should be 9 , 16 - 7

                                    I cannot figure out why I get 14 instaed of 9.


                                Hi Marku,

                                I suggest that you save the parameter of the current bookmark, delete current bookmark and create a new bookmark by using saved parameters. Here is some sample code:

                                ... private void simpleButton1_Click(object sender, EventArgs e) { for (int bmIndex = 0; bmIndex < richEditControl1.Document.Bookmarks.Count; bmIndex++) { string name = richEditControl1.Document.Bookmarks[bmIndex].Name; DocumentPosition bmStart = richEditControl1.Document.Bookmarks[bmIndex].Range.Start; richEditControl1.Document.Delete(richEditControl1.Document.Bookmarks[bmIndex].Range); string newText = "newtext"; DocumentRange docRange = richEditControl1.Document.InsertText(bmStart, newText); richEditControl1.Document.CreateBookmark(docRange, name + bmIndex.ToString()); } } ...
                                Try this solution, and notify us of your results. Thanks for your feedback in advance.


                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners