C#winform的Richtextbox控件实现自动滚动到最后一行功能

这里有两种情况

       如果是采用的是richtextbox的AppendText的方法添加的内容,则只需

设置HideSelection为false

       如果采用的是其他添加内容的方法,则需要添加TextChanged事件方法

 private void txb_ReciveData_TextChanged(object sender, EventArgs e)
        {
            txb_ReciveData.SelectionStart = txb_ReciveData.Text.Length; //Set the current caret position at the end
            txb_ReciveData.ScrollToCaret(); //Now scroll it automatically
        }

 

   

posted on 2018-01-31 16:28  鲁广广  阅读(922)  评论(0编辑  收藏  举报

导航