can I make a text box do this?

D

djc

I'm looking for a way to display text information on a windows forms app in
a way that as new information is added the newest info is always visible.
The best way to explain is this:

A regular textbox control would work perfectly fine for me if only as I
append text to it, it scrolled to the bottom so the newly added info is
visible and older info can scroll off the top of the textbox.

can I make a text box do this? or is there another control I could use to do
this? I need a control to use as an output screen that will be coninually
written to by several other components of the program. A 'status' output, if
you will.

any input would be greatly appreciated, thanks.
 
A

AHadiA

Hi Djc
You can use ScrollToCaret Method of TextBox (.Net 2.0)
In the following code snippet, I have two textbox, textbox1 is
MultiLine, and a Button:

private void button1_Click(object sender, EventArgs e)
{
textBox1.Text +=textBox2.Text +Environment.NewLine;
textBox1.SelectionStart = textBox1.Text.Length - 1;
textBox1.ScrollToCaret();

}

if you type text in textbox2 and click the button, the new text is
always visible

I hope this helps
A.Hadi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top