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

VulpesRank #55 · 29.2K reputationPosted Mar 1, 2012, 2:08 AM EST
richTextBox1.Text = richTextBox1.Text.Replace.("\r", "").Replace("\n", "");
VulpesRank #55 · 29.2K reputationPosted Mar 1, 2012, 1:30 AM EST
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.
Glenn PattonRank #6,159 · 275 reputationPosted Mar 1, 2012, 2:01 AM EST
Glenn PattonRank #6,159 · 275 reputationPosted Mar 1, 2012, 2:03 AM EST
Glenn PattonRank #6,159 · 275 reputationPosted Mar 1, 2012, 2:45 AM EST
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 :)
VulpesRank #55 · 29.2K reputationPosted Mar 1, 2012, 3:25 AM EST
Answering questions on the forums is really my forte :)