在RichTextBox中打印彩色单词



我写在一个RichTextBox。

如何使lineItems和j+1变量以红色打印?

例如(in bold = red): Element growthough 4第1列中,没有被正确写入。

   private void button2_Click(object sender, EventArgs e)
            {
//  Numbers-IDs
        if (colB[j] == "int_number")
        {
           if (!arithmos(lineItems[j]))
               richTextBox1.Text += "Element    " + lineItems[j] + "t in   " + (j + 1) + "th coloumn,has not been writen right" + Environment.NewLine;
        }
// Alphanumeric  
        else if (colB[j] == "alpharithmitiko")
        {
              if (!numword(lineItems[j]))
                  richTextBox1.Text += "Element    " + lineItems[j] + "   in  " + (j + 1) + "th coloumn,has not been writen right " + Environment.NewLine;
        }

//Words
        else if (colB[j] == "words")
        {
                if (!word(lineItems[j]))
                    richTextBox1.Text += "Το στοιχείο    " + lineItems[j] + "    in  " + (j + 1) + "th coloumn,has not been writen right" + Environment.NewLine;
        }
//Date
        else if (colB[j] == "date")
        {
             if (!date(lineItems[j]))
                 richTextBox1.Text += "Το στοιχείο    " + lineItems[j] + "    in  " + (j+1) + "th coloumn,has not been writen right" + Environment.NewLine;
          }
}

你可以试试这个…

if (!arithmos(lineItems[j]))
richTextBox1.Text += "Element    " + lineItems[j] + "t in   " + (j + 1) + "th coloumn,has not been writen right" + Environment.NewLine;
richTextBox1.SelectionColor = Color.Red;
richTextBox1.AppendText(j + 1);

最新更新