blah blah blah is here! blah blah » Close

up0down
link

Hello, I'm developing an application in which I need to copy the content of a richtextbox with all its font settings to another richtextbox.

the code i use is like this

this.chatTxt.SelectionStart = this.chatTxt.Text.Length;

this.chatTxt.SelectionLength = 0;

this.chatTxt.SelectedRtf = this.recvTxt.Rtf;


this should work just fine, however in the chatTxt box does appear only the plain text. if a rtf text is send it does not show.

do anyone know how to solve this issue?

last answered one year ago

2 answers

up0down
link

Try it like this instead:

this.recvTxt.SelectionStart = 0;
this.recvTxt.SelectionLength = this.recvTxt.Text.Length;
this.chatTxt.SelectionStart = this.chatTxt.Text.Length;
this.chatTxt.SelectionLength = 0;
this.chatTxt.SelectedRtf = this.recvTxt.SelectedRtf;

it does not help. if the text is in RTF it is not copied, only if it is plain text.

up0down
link

my apologies.

the error was hiding somewhere else.

the correct code to copy text from one form to another is:

this.chatTxt.SelectionStart = this.chatTxt.Text.Length;

this.chatTxt.SelectionLength = 0;

this.chatTxt.SelectedRtf = this.recvTxt.Rtf;


best of luck

Feedback