Copy from RichTextBox1 to RichTextBox2 changes text layout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desertavataraz
    New Member
    • Jan 2009
    • 14

    Copy from RichTextBox1 to RichTextBox2 changes text layout

    My main form has a RichTextBox, the contents of the RichTextBox has section numbers, i.e, S1, S2, S3 etc. I am using these section numbers to allow the reader to view a particular section in a seperate window, while reading the main text. For example, suppose they want to see a chart relevant to chapter 3 that is in the index, so they put in the section number and click the section button and the code finds the section start and end, then:

    Me.RichTextBox1 .Select(indexTo SectionStart, sectionLength)
    FrmSection.rtbS ection.Text = Me.RichTextBox1 .SelectedText

    So if we are studying Latin, for example, in the new window, we will get this chart from the index: (ignore the hypens, they are there to show how the text spacing appears)

    - - - -S374.
    - - - - - - - Present Indicative
    - - - - - -porto - - - - - -portamus
    - - - - - -portas - - - - - portatis
    - - - - - -portat - - - - - portant

    But the problem is, instead, I am getting things like this:

    - - - -S374.
    - - - - - - - Present Indicative
    - - - - - -porto - - - - - - - - - portamus
    - - - - - -portas - - - - - portatis
    - - - - - -portat - - - - - - - - - portant

    The settings for the two textboxes are identical, except for the size of the text box and the location of the textbox on the screen, and neither appear to effect the result, so I am fishing for ideas on why this is happening and how to solve the problem.
  • desertavataraz
    New Member
    • Jan 2009
    • 14

    #2
    I was able to find a solution to this problem, using the code I found on the internet at:
    The home for technical questions and answers at Microsoft. Get started asking, answering, and browsing questions about products like .Net, Azure, or Teams.


    The code is listed below:

    RichTextBox1.Co py()
    Dim atext As IDataObject
    atext = Clipboard.GetDa taObject()
    Dim RTFdata As String = atext.GetData _
    (DataFormats.Rt f).ToString()
    FrmSection.rtbS ection.Rtf = RTFdata

    This copies it to the clipboard instead of copying it from textboxt to textbox. The only problem I have with it is it does not allow me to append the text from the clipboard with the text already in the FrmSection textbox, but I think i can live with that . . .

    Comment

    Working...