2011-10-17 35 views
0

我正在RichTextBox中写入文字。在RichTextBox中打印彩色文字

如何在红色中打印lineItems和j + 1变量。

例如(以粗体=红色):Growthougth在列,一直没有writen右。

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

什么是你的问题? – Reniuz

+0

@Reniuz看看我的编辑 –

+0

正在改变文字forecolor不工作? – Reniuz

回答

0

你可以试试这个..

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); 
+0

我在哪里写这个?在if语句下?在方法内部还是外部? –

+0

当你得到** j **的价值.. –

+0

你是什么意思_got_?我有一个带''''变量的'for-statement',我有时单独打印它,有时会打印'lineItems [j]'。哪里? –