By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 1,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

Rich Text Box and Cr Lf

P: n/a
I have written a small terminal app that reads and writes to the serial port. In particular as the data is read from the serial port it is appended to the rich text box. The problem I am experiencing is this:

When CrLf is received in the same read and appended to the rich text box, it processes it by moving to the beginning of the next line. This is right.

When Cr is received at the end of one read it is appended to the rich text box. Then Lf is received at the beginning of the next read it is also appended to the rich text box. However, the rich text box appears to place a Lf with the Cr and then it receives the next Lf. The effect is that it skips down two lines instead of one. This incorrectly shows the data.

Is there anyway to overcome this?
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I think replacing a CR by a CRLF is just a way of RichText trying to correct, what it thinks is a mistake.

One way is to check if the last char read is a CR and if so take it off the text added to the Rich Text. Then add the removed character to the next set of text that you read in. That should solve the problem of two CRLF.

--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com
"Peter" wrote:
I have written a small terminal app that reads and writes to the serial port. In particular as the data is read from the serial port it is appended to the rich text box. The problem I am experiencing is this:

When CrLf is received in the same read and appended to the rich text box, it processes it by moving to the beginning of the next line. This is right.

When Cr is received at the end of one read it is appended to the rich text box. Then Lf is received at the beginning of the next read it is also appended to the rich text box. However, the rich text box appears to place a Lf with the Cr and then it receives the next Lf. The effect is that it skips down two lines instead of one. This incorrectly shows the data.

Is there anyway to overcome this?

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.