To contact us Click HERE
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.
Hiç yorum yok:
Yorum Gönder