我在RichTextBox中写作。
如何使lineItems和j + 1变量以红色打印。
例如(粗体=红色): 4 列中的元素 Growthougth ,尚未正确写入。
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 :(得分: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);