Click here to Skip to main content
Licence CPOL
First Posted 3 Aug 2009
Views 10,184
Downloads 150
Bookmarked 12 times

Scrollbar in Down Side of Textbox

By | 3 Aug 2009 | Article
Scrollbar in down side of textbox

Introduction 

This is an article to solve a simple problem. I mean to set scrollbar at the end of the text in textbox when dynamically updating the text value on that textbox.

Description

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

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

Actually I have been developing a big application. In 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 have been set. But I could only see the vertical bar not going down when updating the status as shown in the below figure which is marked in red.

scrolldown1.JPG

After Googling for a few minutes, I found that we have some properties and methods in textboxes of Visual Studio - SelectionStart and ScrollToCaret methods.

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

scrolldown2.JPG

Using the Code 

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();
}

Conclusion

Hence my doubt has been solved. :)

History

  • 3rd August, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

S.Vinothkumar

Web Developer

India India

Member

Hi Viewers,

I wish to all. This is Vinoth. This is where I try to condense everything that you need to know about me.
 
Blog:
 
visit my blog
 
Interests:

I'm passionate about a great many things and continually learning about the things that interest me. They are wearable computers, User Interface Design, Artificial life, Industrial music.
 

 

 


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAnother Solution PinmemberCihan Topçu2:58 4 Aug '09  
GeneralMy vote of 1 PinmemberNeni-san0:09 4 Aug '09  
GeneralMy vote of 1 Pinmemberpatrak21:50 3 Aug '09  
GeneralMy vote of 2 PinmemberAshutosh Bhawasinka6:06 3 Aug '09  
GeneralMy vote of 3 Pinmemberalrsds16:45 23 Sep '09  
GeneralMy vote of 1 Pinmemberjon2115:07 3 Aug '09  
GeneralMy vote of 1 PinmemberMichael E. Jones4:24 3 Aug '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 3 Aug 2009
Article Copyright 2009 by S.Vinothkumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid