Scrollbar in down side of textbox.

No.of Views1033
Bookmarked0 times
Downloads 
Votes0
By  vinothnat   On  15 Feb 2010 22:02:38
Tag : CSharp , Windows Forms
Scrollbar in down side of textbox.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

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 has 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.

Image Loading....

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

Image Loading....

C# Code :

{codecitation class="brush: csharp; gutter: true;" width="650px"}

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

}

{/codecitation}

Thank you

...S.VinothkumaR.

 
Sign Up to vote for this article
 
About Author
 
vinothnat
Occupation-Not Provided
Company-Not Provided
Member Type-Junior
Location-Not Provided
Joined date-03 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top