给一些相关的语句,自己打理吧
int currentIndex;richtext.text.IndexOf("mytype",currentIndex,ricthtext.txt.length-currentIndex);rtbox_MessageHistory.AppendTextAsRtf("test", new Font(this.Font, FontStyle.Bold), RtfColor.Blue, RtfColor.Yellow);
int currentIndex;richtext.text.IndexOf("mytype",currentIndex,ricthtext.txt.length-currentIndex);rtbox_MessageHistory.AppendTextAsRtf("test", new Font(this.Font, FontStyle.Bold), RtfColor.Blue, RtfColor.Yellow);
///
///str:要输入的字符
///wc :字符的颜色
private void WriteLine(string str,Color wc)
{
string Style ;
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength =richTextBox1.Text.Length ;
Style=richTextBox1.SelectedRtf;
richTextBox1.Text = str+"\r\n";
richTextBox1.SelectedRtf=Style;
if(wc != Color.Transparent)
{
richTextBox1.SelectionStart =richTextBox1.Text.Length -str.Length -1;
richTextBox1.SelectionLength = str.Length+1;
richTextBox1.SelectionColor = wc;
}
}
{ "select",
"insert",
"update",
"delete",
"create",
"table",
"union",
"from",
"where",
"=",
"<>",
"(",
")",
"in",
"and",
"or",
"set",
"values",
"into",
"int",
"char",
"date",
"drop",
"commit",
"rollback"
};
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/// <summary>
/// 对关键字进行字体设置
/// </summary>
/// <param name="pSql"></param>
/// <returns></returns>
private void SetTextFormat()
{
string m_sql = CommandRTextBox.Text.ToLower();
int SelPos = CommandRTextBox.SelectionStart;
for(int i = 0; i < KeyWords.Length;i++)
{
try
{
CommandRTextBox.SelectionStart = m_sql.IndexOf(KeyWords[i]);
}
catch
{
continue;
} CommandRTextBox.SelectionLength = KeyWords[i].Length;
CommandRTextBox.SelectionFont
= new System.Drawing.Font("黑体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
CommandRTextBox.SelectionColor = System.Drawing.Color.Blue;
}
CommandRTextBox.Select(SelPos,0);
CommandRTextBox.SelectionColor = System.Drawing.Color.Black;
}