C# text控件的使用

 GoogleLog.SelectionStart = GoogleLog.TextLength;
 GoogleLog.ScrollToCaret();
 
 /// <summary>
        /// 把页面滚动条滚动到最后面
        /// </summary>
        public void WebFormScrollToEnd()
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new DelegateManager.NoParameters(WebFormScrollToEnd));
            }
            else
            {
      
                webForm.Document.Window.ScrollTo(100, 1000000);
            }
        }
 
//清除text日志控件多余字符串
 public void WriteLog(string strLog)
        {
            if (this.InvokeRequired)//控件的 Handle 是在与调用线程不同的线程上创建的(说明您必须通过 Invoke 方法对控件进行调用),为 true;否则为 false。 
            {
                this.BeginInvoke(new DelegateManager.OneStringParmenters(WriteLog), strLog);
            }
            else
            {
                if (txtLog.Text.Length > 10000)
                {
                    txtLog.Text = txtLog.Text.Substring(txtLog.TextLength - 10000);
                }
                txtLog.AppendText(string.Format("{0}:{1}\r\n", DateTime.Now.ToString("G"), strLog));
            }
        }
posted @ 2012-10-17 23:42  陀螺-  阅读(696)  评论(0编辑  收藏  举报