TEXTBOX SCROLLBAR ALWAYS STAY AT THE BOTTOM?

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
C# 
C#
 1406  View(s)
Ratings:
Rate this:

Is there a way i can make sure my textbox scroll bar always stays at the bottom because my textbox is my messages. It looks alot better if it is at the bottom

At the start it changes my text to the text from a database so i just did this void

private void frmMain_TextChanged(object sender, EventArgs e)

{

    textBox1.SelectionStart = textBox1.Text.Length;

    textBox1.ScrollToCaret();

}

but it didnt work. Is there any other ways? I also tryed putting them 2 codes in Form1_Load

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Textbox scrollbar always stay at the bottom?

    Hi Jayden,

    Add your code for the Shown event for your Form so you 'would end up with code like this:

    private void Form1_Shown(object sender, EventArgs e)

        {

            textBox1.SelectionStart = textBox1.Text.Length;

            textBox1.ScrollToCaret();

        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!