我要保持一定數量的RichTextBox的線,所以我做了以下內容:在richtextbox中保留一定數量的行嗎?
private void txt_Log_TextChanged(object sender, EventArgs e)
{
int max_lines = 200;
if (txt_Log.Lines.Length > max_lines)
{
string[] newLines = new string[max_lines];
Array.Copy(txt_Log.Lines, 1, newLines, 0, max_lines);
txt_Log.Lines = newLines;
}
txt_Log.SelectionStart = txt_Log.Text.Length;
txt_Log.ScrollToCaret();
}
但運行時我Richtextnbox連續閃爍,所以我應該怎麼做這個光滑?
我相信當你再次更新'txt_Log.Lines'屬性的值,則'txt_Log_TextChanged'事件觸發。你可以調試代碼來驗證它嗎? – Dmitry