public void AppendOutputText(string content) { // 对于该控件的请求来自于创建该控件所在线程以外的线程 if (rtbOutput.InvokeRequired) { var rtbSet = new DelegateRichTextBox(delegate(RichTextBox tb, string cnt) { // 设置插入点的字体 tb.SelectionFont = new Font(tb.Font.FontFamily, 10.5f); tb.AppendText(cnt); // 控制最大行数 Utils.RichTextBoxMaxLineControl(tb); tb.ScrollToCaret(); //让滚动条拉到最底处 }); rtbOutput.Invoke(rtbSet, rtbOutput, content); } else { // 设置插入点的字体 rtbOutput.SelectionFont = new Font(rtbOutput.Font.FontFamily, 10.5f); rtbOutput.AppendText(content); // 控制最大行数 Utils.RichTextBoxMaxLineControl(rtbOutput); rtbOutput.ScrollToCaret(); //让滚动条拉到最底处 } }
public void AppendText(string content) { // 对于该控件的请求来自于创建该控件所在线程以外的线程 if (RtbShell.InvokeRequired) { var rtbSet = new DelegateRichTextBox(delegate(RichTextBox tb, string cnt) { // 设置插入点的字体 tb.SelectionFont = new Font(tb.Font.FontFamily, 10.5f); tb.AppendText(cnt); // 控制最大行数 Utils.RichTextBoxMaxLineControl(tb); tb.ScrollToCaret(); //让滚动条拉到最底处 _oldLength = tb.TextLength; // 获取richtextbox中已有内容长度 }); RtbShell.Invoke(rtbSet, RtbShell, content); } else { // 设置插入点的字体 RtbShell.SelectionFont = new Font(RtbShell.Font.FontFamily, 10.5f); RtbShell.AppendText(content); // 控制最大行数 Utils.RichTextBoxMaxLineControl(RtbShell); RtbShell.ScrollToCaret(); //让滚动条拉到最底处 _oldLength = RtbShell.TextLength; // 获取richtextbox中已有内容长度 } }
public static void WriteServerLog(RichTextBox textBox, string content) { // 对于该控件的请求来自于创建该控件所在线程以外的线程 if (textBox.InvokeRequired) { var rtbSet = new DelegateRichTextBox(delegate(RichTextBox tb, string cnt) { tb.AppendText(cnt + "\r\n"); // 控制最大行数 Utils.RichTextBoxMaxLineControl(tb); tb.ScrollToCaret(); //让滚动条拉到最底处 }); textBox.Invoke(rtbSet, textBox, content); } else { textBox.AppendText(content + "\r\n"); // 控制最大行数 Utils.RichTextBoxMaxLineControl(textBox); textBox.ScrollToCaret(); //让滚动条拉到最底处 } }