none
wpf richtextbox erroneously combines ordered lists in documents loaded from files

    Question

  • I have searched for a solution to my issue off and on for a couple of years now and finally decided I really want to resolve this problem and to post a request for help.

    I have a VS2010 app that uses rtb for a custom editor.  The documents are saved to rtf files and are loaded via:

                     fs = New FileStream(strFilename, FileMode.Open, FileAccess.ReadWrite)

                     RTBText.Load(fs, DataFormats.Rtf)

    Everything works fine except for bullet and ordered lists.  My problem is that lists are correctly created in the documents and correctly saved.  However the lists and all paragraphs between the lists are all lumped into one list when they are reloaded into rtb.  When I select any piece of the now combined list and change the textmarkerstyle every item, i.e. including those not selected!, are also changed.

    I have verified the files are correctly formatted by loading them in Wordpad.  The ordered lists appear correct when they are created in rtb, to emphasize-- they appear correctly in Wordpad when loaded, but on reloading in rtb the separate lists are combined into one with all paragraphs also included in the now garbled list.

    For example:

    when created and also when loaded into Wordpad the document appears as:

    paragraph not including with list
    paragraph outside lists
    paragraph 2 outside lists

            1.    list item 1 in list1
            2.    list item 2 in list1
            3.    list item 3 in list1

    paragraph outside list

           1.    list item 1 of list2
           2.    list item 2 in list 2

    paragraph 2 outside list

    However when loaded back into the rtb they appear as:

    paragraph not including with list
    paragraph outside lists
    paragraph 2 outside lists

           1.    list item 1 in list1
           2.    list item 2 in list1
     3.              list item 3 in list1

           paragraph outside list

           4.    list item 1 of list2
           5.    list item 2 in list 2

    paragraph 2 outside list

    The above list shows the two lists combined as one, the margin and padding of number 3 is incorrect and the paragraph between the lists has erroneously been indented as it now is part of the garbled list. 

    I have looked into trying to repair the lists after loading but don't understand how I can separate the individual lists out from the continuous list and keep paragraphs not intended as part of any list in the correct area of the document.

    How can I either programmatically repair the document before or after loading into the rtb; or is there some fix available I have not discovered?

    Thanks in advance for any help.

    Tuesday, January 27, 2015 4:14 AM

Answers