Печать цветных слов в RichTextBox - PullRequest
0 голосов
/ 17 октября 2011

Я пишу в RichTextBox.

Как сделать так, чтобы lineItems и переменная j + 1 были напечатаны в красном .

Например (жирным шрифтом = красный): Элемент Рост в 4 -й столбец, неправильно записано.

   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;
          }
}

1 Ответ

0 голосов
/ 17 октября 2011

Вы можете попробовать это ..

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);
...