We help IT Professionals succeed at work.

Combining RTFs into a single one for richtextbox.rtf

zipnotic
zipnotic asked
on
Medium Priority
40 Views
Last Modified: 2020-03-18
I am trying to combine a series of rtf into a single one for display into a richtextbox.rtf property.

I'm using the following code to trim the first and last characters so they all display at once but the last RTF is being ignored.  Everything up until the last rtf is displaying perfectly.  After a couple of hours of fiddling I still can't figure out how to properly concatenate and terminate these things.

Here's the code to remove trailing characters of the first RTF and leading character of subsequent RTFs then add in the trailing characters at the end.  I think I tried various combinations thereof but I'm hoping someone with more RTF knowledge can point me in the right direction?



Thanks

                For i = 0 To dsRM.Tables("Narratives").Rows.Count - 1
                    If i = 0 Then
                        NarrativeText += dsRM.Tables("Narratives").Rows(i)("NarrativeRTF")
                        NarrativeText = NarrativeText.Substring(0, NarrativeText.Length - 3)
                        trailingthree = NarrativeText.Substring(NarrativeText.Length - 3)
                    End If


                    If i > 0 Then
                        tempNar = dsRM.Tables("Narratives").Rows(i)("NarrativeRTF")
                        NarrativeText += tempNar.Substring(1, tempNar.Length - 1)
                    End If

                Next
                NarrativeText += trailingthree
                MsgBox("added last r} back in")

                richtextbox1.rtf = NarrativeText
Comment
Watch Question

Commented:
I used the .text property of a temporary richtextbox to capture just the text and pasted that into the visible richtextbox.  It loses the formatting of the original RTF but it was good enough.