Using a multiline text box for logging

Just a quick note… if you have a winforms app, you can log what is happening to a multiline textbox (normally set to readonly). To ensure that the last message added is visible, run code as follows everytime you add a log message.

textBoxMessages.Text += string.Format("{0}\r\n", aMessage);
textBoxMessages.SelectionStart = textBoxMessages.Text.Length - 1;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>