2011-10-17 113 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]'。哪裏? –