zoukankan      html  css  js  c++  java
  • WPF TextBox自动滚动到最户一行

    textBox经常用来显示程序的运行状态或者消息,如何让他自动滚动呢?

    在显示消息代码下加一条自动滚动到底部的语句即可:

     TextBox1.ScrollToEnd();

    (如果要显示垂直滚动条设置VerticalScrollBarVisibility="Auto",如果不显示设置为Hidden)

    我用的程序代码如下:

    this.Dispatcher.Invoke(new Action(() =>
    {
        //大于100行清除记录,可选
        if (txtReceived.LineCount > 100)
        {
            txtReceived.Clear(); 
        }
        txtReceived.AppendText(string.Format("当前时间{0:HH:MM:ss}
    ", DateTime.Now));
        //自动滚动到底部
        txtReceived.ScrollToEnd(); 
    }));
    

      

  • 相关阅读:
    html表单
    html基础
    MySQL数据库 数据的更新
    JAVA数据库编程
    集合框架
    线程和进程
    反射
    centos 7环境
    js中的this
    javascript的作用域以及闭包现象
  • 原文地址:https://www.cnblogs.com/sntetwt/p/5360990.html
Copyright © 2011-2022 走看看