日期:2014-05-18 浏览次数:20995 次
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;
}
}