标签:c# 位置 private required box sel back this text
private delegate void SetTextCallback(string text);
private delegate void SetSelectCallback(object Msge);
private void SetText(string tt)
{
string text = tt;
try
{
if (this.richTextBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
if (this.richTextBox1.Lines.Length < Properties.Settings.Default.textclearLength)
{
this.richTextBox1.AppendText(text);
of_SetRichCursor(richTextBox1);
}
else
{
this.richTextBox1.Clear();
}
}
}
catch (Exception)
{
}
}
private void of_SetRichCursor(object msge)
{
try
{
RichTextBox richbox = (RichTextBox)msge;
//设置光标的位置到文本尾
if (richbox.InvokeRequired)
{
SetSelectCallback d = new SetSelectCallback(of_SetRichCursor);
this.Invoke(d, new object[] { msge });
}
else
{
richbox.Select(richbox.TextLength, 0);
//滚动到控件光标处
richbox.ScrollToCaret();
}
}
catch (Exception)
{
}
}
标签:c# 位置 private required box sel back this text
原文地址:http://www.cnblogs.com/ssjsk/p/6362084.html