By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,401 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,401 IT Pros & Developers. It's quick & easy.

Copy from RichTextBox1 to RichTextBox2 changes text layout

P: 14
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(indexToSectionStart, sectionLength)
FrmSection.rtbSection.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.
Nov 24 '09 #1
Share this Question
Share on Google+
1 Reply


P: 14
I was able to find a solution to this problem, using the code I found on the internet at:
http://social.msdn.microsoft.com/For...3-1fd82693d340

The code is listed below:

RichTextBox1.Copy()
Dim atext As IDataObject
atext = Clipboard.GetDataObject()
Dim RTFdata As String = atext.GetData _
(DataFormats.Rtf).ToString()
FrmSection.rtbSection.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 . . .
Nov 24 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.