日期:2014-05-18  浏览次数:20802 次

RichTextBox高亮显示 输入内容时滚动条不停的滚动,文本也在闪烁

RichTextBox高亮显示 输入内容时滚动条不停的滚动,文本也在闪烁

C# code

private void tSql_TextChanged(object sender, EventArgs e)
{
string tokens = "(module|export|define|include|record|gen_tcp:listen|io:fwrite|lists:foreach|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|if|static|while)";
            Regex rex = new Regex(tokens);
            MatchCollection mc = rex.Matches(tSql.Text);
            int StartCursorPosition = tSql.SelectionStart;
            foreach (Match m in mc)
            {
                int startIndex = m.Index;
                int StopIndex = m.Length;
                tSql.Select(startIndex, StopIndex);
                tSql.SelectionColor = Color.Blue;
                tSql.Select(StartCursorPosition, 0);
                //tSql.SelectionStart = StartCursorPosition;
                tSql.SelectionColor = Color.Black;
            }
}



请帮助我,输入内容时,怎样让内容不闪烁,滚动条不自动滚动,非常感谢。

------解决方案--------------------
看看这个吧
http://www.cnblogs.com/birdshover/archive/2007/01/30/635230.html
------解决方案--------------------
你有一个foreach啊,循环选择,取消的,怎么能不闪呢,你还是固定好选哪个吧,不要循环变化