Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make autoscroll multiline TextBox in WinForms? [duplicate]

Tags:

Possible Duplicate:
How do I automatically scroll to the bottom of a multiline text box?

I use a multiline TextBox to output some information in new lines as it arrives from a BackgroundWorker.

Can I make it to scroll to the very bottom each time a new line arrives?

By default it seems to do just the opposite - it scrolls to the very first line each time a new line arrives and the Text property is changed.

like image 468
Ivan Avatar asked Nov 22 '12 02:11

Ivan


People also ask

How do I enable multiline in a text box?

Step 1: Create a windows form. Step 2: Drag the TextBox control from the ToolBox and drop it on the windows form. You can place TextBox anywhere on the windows form according to your need. Step 3: After drag and drop you will go to the properties of the TextBox control to set the Multiline property of the TextBox.

How do I scroll a text box in C#?

// Creating textbox TextBox Mytextbox = new TextBox(); Step 2 : After creating TextBox, set the ScrollBars property of the TextBox provided by the TextBox class.

What is multiline in TextBox?

A multiline text box control is a large text box that can display several lines of text or accept this text from user input. Text boxes are often linked to select value lookups and detailed menus. You can place a multiline text box control within a section control.

What is multiline TextBox in VB net?

A multiline text box allows you to display more than one line of text in the control. If the WordWrap property is set to true , text entered into the multiline text box is wrapped to the next line in the control.


1 Answers

Set the TextBox properties:

Multiline = True;
ScrollBars = Both;

To auto scroll on the TextChanged event:

textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();
like image 138
Patrick Guimalan Avatar answered Sep 30 '22 18:09

Patrick Guimalan