[.net] How to give line number in a textBox?

This topic is 3782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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]

Share on other sites
For every line inserted, prepend a padded line number.
If that's ugly, consider using some other control, like a multi-column list control.

Share on other sites
How to do this?
"For every line inserted, prepend a padded line number."

Thank you very much..

Share on other sites
i = 1
for each line
line = i++ + line

Share on other sites
Quote:
 Original post by chrisliando2. 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.

Share on other sites
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..

Share on other sites
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?

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).

Share on other sites
No, everything is ok for me. If there is source code, then I will use it, if not it's also ok. I just confused.

But how to integrate the multi-column list control with the textBox?

Thank you.

• 11
• 20
• 12
• 10
• 37
• Forum Statistics

• Total Topics
631400
• Total Posts
2999860
×