【发布时间】:2012-06-16 17:01:06
【问题描述】:
关于单行文本框(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.SelectionStart = PathText.Text.Length;
-
你是对的;当我输入问题时,我最初复制了尚未编译的旧代码。感谢您查看它。