How to move bold text to another richtextbox?

Ok, I'll just leave my code here .

As you can see from this code, there is a button to make the text bold , but not all the text, just the next thing that the user will write.

For example, when the user types abc, presses the button, type def: he gets: abc def .

But by using: richtextbox2.text = richtextbox1.text;, richtextbox2.textvalue becomes abcdefinstead abc def .

I want to copy the exact text, including bold text.

Thank.

+3
source share
3 answers

use the RTF property of the text field, not the Text property ...

richtextbox2.Rtf = richtextbox1.Rtf
+2
source

, essedbl, , , RTF, SelectedText...

, SelectionStart SomeRTFControl.Text.Length SelectionLength 0.

SelectedText , , SelectionX , , .. , .

/, , RTF, . ​​

, .

+1

:

this.rtxtReport.Rtf = "{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 Tahoma;}}";
this.rtxtReport.Rtf += "{\\colortbl;\\red0\\green0\\blue0;\\red255\\green0\\blue0;}";
this.rtxtReport.Rtf += "{\\header\\pard\\qr\\plain\\f0\\chpgn\\par}";
this.rtxtReport.Rtf += "{\\pard{\\b ";
this.rtxtReport.Text += this.Ln + "> " + "VSTFS Report - " + System.DateTime.Now;
this.rtxtReport.Rtf += " \\b}\\par}";

The only way I managed to highlight bold text is to select it, which is not practical, I create a document from scratch, you will need to select the text that you add, it made bold this text, but everything else added later ! ... the choice (beginning, length) has a length on it, so there is a bust.

Does anyone really get C # for bold text using rtf formatting and not highlighting the text?

0
source

All Articles