RichTextBox RTF Problems

Machaira

Junior Contributor
Joined
Aug 19, 2002
Messages
325
Location
Abingdon, MD
I'm trying to use the Rtf property of a RichTextBox as a string, but I'm running into problems with concatenating it with other strings. Anything after the Rtf text is cut off. Has anyone noticed problems with this and, if so, found a fix?

Attached is a simple project so you can see what I mean. Just type some text into the box and click the button. Notice the string after the Rtf text does not get printed in the Output window.
 

Attachments

That's really weird. I get that behaviour too, even using StringBuilder to concatenate text. I was half thinking I wouldn't be able to reproduce it because I'm using VS.NET 2003, but I am.

If I try and concatenate the string using the command window however, it works. It would be worth a post in the newsgroups to see what MS says about it.
 
Posted the problem to the MS newsgroups and got an answer. It appears null characters are tacked on the end of the RTF text which prevents anything from being concatenated to it. Calling the Rtf property's Replace function to replace the nulls with an empty string seems to fix it.
 
Back
Top