【问题标题】:Printing colored words in RichTextBox在 RichTextBox 中打印彩色单词
【发布时间】:2011-10-17 18:51:58
【问题描述】:

我在 RichTextBox 中写作。

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

例如(粗体=红色):元素Growthougth在第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;
          }
}

【问题讨论】:

标签: c# richtextbox


【解决方案1】:

你可以试试这个..

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

【讨论】:

  • 我在哪里写这个?在 if 语句下?在方法内部还是外部?
  • 你是什么意思得到?我有一个for-statement 和j 变量,我有时单独打印它,有时打印lineItems[j]。在哪里?
猜你喜欢
  • 2013-06-22
  • 2021-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-14
  • 1970-01-01
  • 2013-01-18
  • 2023-04-06
相关资源
最近更新 更多