Scroll to the end of a Single-Line Textbox in C#
.net, c#, winforms
Solution
You could do something like this:
PathText.Focus();
PathText.Select(PathText.Text.Length, 0);
Problem
In regards to single-line textboxes (Multiline property is set to false), is it possible to scroll to the end of the line when the text length exceeds the horizontal size of the box? I have tried various solutions that work for multi-line boxes, but none of them have worked thus far. Very similar questions have been asked by several individuals in the past, but it has always regarded Multi-Line textboxes. The questions/solutions that I have come across on SO are the following: Scroll to bottom of C# TextBox How do I automatically scroll to the bottom of a multiline text box? Right now I have the following code (which seemingly does not work): ``` PathText.Text = ""; PathText.AppendText(BrowseDialog.SelectedPath); PathText.SelectionStart = PathText.TextLength; PathText.ScrollToCaret(); PathText.Refresh(); ``` `PathText` is the textbox in use, and `BrowseDialog` is a FileDialog. Any suggestions are greatly appreciated.