Jump to content
  • Advertisement
Sign in to follow this  
chrisliando

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


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

Share this post


Link to post
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 this post


Link to post
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 = 1
for 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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!