关于单行文本框(Multiline属性设置为false),当文本长度超过框的水平尺寸时,是否可以滚动到行尾?
我已经尝试过各种适用于多行框的解决方案,但到目前为止都没有奏效。
过去有几个人问过非常相似的问题,但它一直都在考虑多行文本框。我在 SO 上遇到的问题/解决方案如下:
Scroll to bottom of C# TextBox
How do I automatically scroll to the bottom of a multiline text box?
现在我有以下代码(似乎不起作用):
PathText.Text = "";
PathText.AppendText(BrowseDialog.SelectedPath);
PathText.SelectionStart = PathText.TextLength;
PathText.ScrollToCaret();
PathText.Refresh();
PathText
是正在使用的文本框,BrowseDialog
是一个 FileDialog。
非常感谢任何建议。
最佳答案
你可以这样做:
PathText.Focus();
PathText.Select(PathText.Text.Length, 0);
关于c# - 滚动到 C# 中单行文本框的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11019933/