Thursday, May 2, 2013

Multiline TextBox scroll to bottom automatically



If we want to have our vertical scroll bar in a TextBox (obviously Multiline TextBox) pointing always to the bottom as we write data in the TextBox, we could do this using another way instead of using ScrollToCaret option.

When we write data in TextBox using textBox1.text = “This is my data… bla blah blah….”, by default  the vertical scroll bar always stays at the top. But if we use AppendText propery of textbox, vertical bar automatically comes to bottom whenever data is written in the text box.

                
 textBox1.AppendText(Environment.NewLine);   
 textBox1.AppendText(sMessage);

1 comment: