[.net] How to give line number in a textBox?
1. I want to generate some kind of a log file using a multiline textBox and I have to give line number to it so that it is clear for user to know the detailed events.
How to do that?
2. Everytime there is an event occured, I want to add a new line in the textBox. How to do that? I've tried the textBox->AppendText but it cannot create a new line, it places the appended text next to the last text.
How to solve this?
Thank you very much..
[Edited by - chrisliando on February 11, 2008 12:56:39 AM]
For every line inserted, prepend a padded line number.
If that's ugly, consider using some other control, like a multi-column list control.
If that's ugly, consider using some other control, like a multi-column list control.
Quote:Original post by chrisliando
2. Everytime there is an event occured, I want to add a new line in the textBox. How to do that? I've tried the textBox->AppendText but it cannot create a new line, it places the appended text next to the last text.
If you're not including "\r\n" before the string to be appended, then you should be. For reasons I've never fully understood, a single '\n' won't do it, the carriage return is necessary.
So how to combine "\r\n" with this:
i = 1
for each line
line = i++ + line
How?
And how to make the line number to be not selectable?
Thank you very much..
i = 1
for each line
line = i++ + line
How?
And how to make the line number to be not selectable?
Thank you very much..
Are you asking for a source-code solution that you can copy/paste?
Or are you asking us to explain the concept of string concatenation?
To make the line number not selectable, you'd be better off using a different approach all together, "like a multi-column list control" (to quote Zao).
Or are you asking us to explain the concept of string concatenation?
i = 1for each line line = i++ + line + "\r\n"
To make the line number not selectable, you'd be better off using a different approach all together, "like a multi-column list control" (to quote Zao).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement