Hi All,
Funny one I am updating a rich text from a data source with following
rtbUnlistedData.Text += Data_From_PitStop+ '\n';
Which works fine with some data but an update to the code causes the string to be broken oddly extra carriage return creeps in what I am wondering is does the rich text box handle its text property like a string as a Null on the end seems to be treated as a \n.
Glenn
Loading
VulpesPosted Mar 1, 2012, 7:08 AM
richTextBox1.Text = richTextBox1.Text.Replace.("\r", "").Replace("\n", "");
VulpesPosted Mar 1, 2012, 8:25 AM
Answering questions on the forums is really my forte :)
Glenn PattonPosted Mar 1, 2012, 7:45 AM
richTextBox1.Text = richTextBox1.Text.Replace.("\r", "").Replace("\n", "");
If your not a Author you really ought to think about it! I'm sure I'm not the only person here that would buy a book you had written (I owe you enough already)
Glenn :)
Glenn PattonPosted Mar 1, 2012, 7:03 AM
Glenn PattonPosted Mar 1, 2012, 7:01 AM
VulpesPosted Mar 1, 2012, 6:30 AM
If the WordWrap property is set to true, then it may appear that the RTB is adding line breaks to your text but in fact it is not doing. You can tell that this is so by checking the Lines property which will only contain one element.
If you add your own line breaks, then they should work as expected i.e. the rest of the text should start on a new line. The Lines property will then contain an additional element for each line break.
If you're using Windows then I'd add "\r\n" rather than '\n' though some folks prefer to use Environment.NewLine instead.