Click here to Skip to main content
15,795,331 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
	I am trying to   show the text from a richTexBox to a second text box which, I am able to do.
However the formatting is not retained, I would like to retain the formatting from the first text box in the second.

The problem is not the names of the text boxes it must be some form of  instruction that i am missing

What I have tried:

     If EditBoxA.Text IsNot "" Then 'check if EditBoxA contains string
         EditBoxB.Text = EditBoxA.Text
     End If
 End Sub
 ' and then

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click, Button55.Click
     EditBoxA.Text = EditBoxB.Text
 End Sub
Updated 30-Jun-23 6:17am
Comments 30-Jun-23 11:05am    
Is this WinForms or WPF or whatelse?

Do you have a richTextBox and a textBox
2x richTextBox ?

You are copying from the wrong source.
If RichTextBox1.Text IsNot "" Then 'check if RichTextBox1 contains string
    RichTextBox2.Text = TextBox1.Text ' this is not RichTextBox1
End If

This is a classic example of the sort of problem that can arise when you use the default names for your controls.
Share this answer
Well, you're copying what's in the Text property of the RTB, which doesn't have the formatting information.

Look at the Rtf property[^] instead.
Share this answer
Richard MacCutchan 3-Jul-23 11:38am    
1 vote countered.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900