日期:2014-05-17 浏览次数:20835 次
private void button1_Click(object sender, EventArgs e)
{
var str = "123"+"\n";
richTextBox1.Select(0, richTextBox1.Text.Length);
richTextBox1.SelectionColor = Color.Black;
richTextBox1.AppendText(str);
richTextBox1.Select(richTextBox1.Text.Length - str.Length, richTextBox1.Text.Length);
richTextBox1.SelectionColor = Color.Red;
}
listBox设置选项颜色
加载时设置this.listBox1.DrawMode=
System.Windows.Forms.DrawMode.OwnerDrawFixed;
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
string s = this.listBox1.Items[e.Index].ToString();
if (s.Contains("初始化成功"))
{
e.Graphics.DrawString(s, this.Font, Brushes.Green, e.Bounds);
}
else if (s.Contains("初始化失败"))
{
e.Graphics.DrawString(s, this.Font, Brushes.Red, e.Bounds);
}
else
e.Graphics.DrawString(s, this.Font, new SolidBrush(this.ForeColor), e.Bounds);
}