Scrollbar in down side of textbox.

Scrollbar in down side of textbox.

Hi all, I have come to give a very simple solution for the below question. The question is

How to set scrollbar in end of the text in textbox when dynamically updating the text value?

Actually I have been developing a big application. On that application I needed to update the status of every action in my application. For the purpose of updating the status, I have used the textbox to show the status with multiline and vertical scrollbar properties. But I could see the vertical bar not going down when updating the status as shown in the below figure which is marked in red.




After googling few minutes I found we have some properties and methods in textboxes of visual studio are SelectionStart and ScrollToCaret method.

By using the above property and method I have found the solution for my question. See the below figure...



Code Snippet:

private void btnUpdate_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtStatus.Text))
txtStatus.Text = txtStatus.Text + Environment.NewLine;
txtStatus.Text = txtStatus.Text + "Status Updated...";

txtStatus.SelectionStart = txtStatus.Text.Length;
txtStatus.ScrollToCaret();
txtStatus.Refresh();
}


...S.VinothkumaR.

4 comments:

Megha said...

In WPF to move the Richbox text to the end there is property like
rtextStatusWindow.ScrollToEnd();
This will take care of vertical scroll bar.

escort said...

Awesome blog Adam!! deneme linki I saw you all in Buffalo and the show was incredible, antalya pansiyonları the best I've ever seen and I can't wait to see the show again in Rochester! It's so great to hear you're having a good time. eskort met you in Cleveland and you seemed so escort kızlar ankara If things go my way, I'll be able to catch up with chat sitesi toptan mallar satış sitesi toptan satış deneme travesti istanbul
derteg deneme escort bayanlar istanbul If you don't know how to spot the difference, just watch any of the Filipinas buying and you'll soon catch on. izmir jigolo Crab-sexers par excellence, it seems there's nothing these people aren't good at! cinema izle

SteveBrad said...

Excellent blog!!!!
thanks for sharing a such a great information.
Generic Viagra

yen le said...

I love reading posts with such a fresh point of view on this interesting topic.
online schooling