给一些相关的语句,自己打理吧
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);

解决方案 »

  1.   

    你要做两个工作,一是判断输入的是否为关键字,二才是显示样式,如果仅仅是不知道显示样式怎么控制的话,查查MSDN就知道了
      

  2.   

    //每输入一行字符就改变颜色
    ///
    ///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;
    }
    }
      

  3.   

    string[] KeyWords = 
                     {  "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;
    }
      

  4.   

    http://search.csdn.net/Expert/topic/2112/2112690.xml?temp=.1628992