【问题标题】:Display selected text of TextBox from beginning从头开始显示 TextBox 的选定文本
【发布时间】:2013-06-03 04:13:27
【问题描述】:

我有一个带有文本框和按钮的简单 silverlight 应用程序,当文本长度超过文本框的宽度时,所选文本始终显示文本的结尾部分,是否可以在有文本的同时从头开始显示文本选择了吗?

我尝试将 SelectionStart 设置为 0,但它不起作用,通过将 SelectionLength 设置为 0 会从头开始显示,但不会选择/突出显示文本。

private void button1_Click(object sender, RoutedEventArgs e)
{
    textBox1.Text = "very looooooooooong text";
    textBox1.SelectAll();
    textBox1.Focus();
}

【问题讨论】:

    标签: c# wpf silverlight


    【解决方案1】:

    您可以使用文本框的 CaretIndex 属性。 像 textBox.CaretIndex = 0;

    【讨论】:

    • 这只是将光标设置在开头,文本没有被选中。 silverlight 也没有这个属性
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-25
    • 1970-01-01
    • 2012-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多