1
foreach (Color b in new ColorConverter().GetStandardValues())
{
   RichTextBox rtf = new RichTextBox();
   string[] s = rtf.Lines;

   richTextBox1.Text += b.ToString() + s.ToString() + "\r\n";
   button1.BackColor = b;
   Application.DoEvents();
   Thread.Sleep(10);        
}

大家好,

我有一个遍历所有 KnownColors 的序列,更改按钮的颜色并在 RTF 中写下每种颜色的名称,每种颜色都在它自己的行中。现在我希望更改每行的字体颜色以匹配每行中颜色的名称。

干杯,N

4

2 回答 2

2

试试这个...

        richTextBox1.Clear();
        foreach (Color b in new ColorConverter().GetStandardValues())
        {
            richTextBox1.SelectionStart = richTextBox1.TextLength;
            richTextBox1.SelectionColor = b;
            richTextBox1.SelectedText = b.ToString() + "\r\n";
            button1.BackColor = b;
            Application.DoEvents();
            Thread.Sleep(10);
        }
于 2013-11-03T17:33:39.460 回答
0

尝试这个。

    foreach (Color b in new ColorConverter().GetStandardValues())
    {
       RichTextBox rtf = new RichTextBox();
       string[] s = rtf.Lines;

       richTextBox1.Text += b.ToString() + s.ToString() + "\r\n";
       richTextBox1.SelectionColor = b;
       button1.BackColor = b;
       Application.DoEvents();
       Thread.Sleep(10);        
    }
于 2013-11-03T17:30:34.457 回答