/// <summary> /// 输出 /// </summary> /// <param name="content"></param> /// <param name="color"></param> private void Output(string content, Color color) { Invoke(new MethodInvoker(delegate () { //超出一万行,清空 this._lines++; if (this._lines > 10000) { this.txtOutput.Text = string.Empty; this._lines = 1; } content += Environment.NewLine; this.txtOutput.SelectionColor = color;//设置文本颜色 this.txtOutput.AppendText(content);//输出文本,换行 this.txtOutput.SelectionStart = this.txtOutput.Text.Length;//设置插入符位置为文本框末 this.txtOutput.ScrollToCaret();//滚动条滚到到最新插入行 })); }