Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store all information about the text of a richtextbox and reconstruct it- c# winforms

Is there a way to store all of the information about the text in a richtextbox (colors, sizes, fonts, etc) and reconstruct it in another richtextbox, which is not in the same form or project?

For example, I have a richtextbox which its text contains multiple fonts and colors, and some lines are centered, and I want to reconstruct it in another richtextbox.

I added that the new richtextbox is not in the same project, so i need to restore the information somewhere (for example, even in a string or a file).

like image 670
Dani Avatar asked Sep 18 '25 14:09

Dani


1 Answers

To copy the text and formatting from one richTextBox to another, simply use:

richtextBox2.Rtf = richtextBox1.Rtf;

The Rtf property is simply a string, so you can do with it whatever you can do with strings.

like image 194
Heinz Kessler Avatar answered Sep 21 '25 04:09

Heinz Kessler