读书人

怎么为RichTextBox多个不同行设置不同

发布时间: 2012-01-23 21:57:28 作者: rapoo

如何为RichTextBox多个不同行设置不同的字体和颜色
小弟不才,请教弱智问题:如何为RichTextBox多个不同行设置不同的字体和颜色?
我想为每次新增加的文本设置字体的颜色,可是,下次新增文本时,原来那些被设置过字体和颜色的文字又变成了默认的字体和颜色,只有最后一次的设置才有效果,我的代码如下。

int startIndex = this.receiveBox.Text.Length;
// message是接收到的字符串.
this.receiveBox.Text += message + Environment.NewLine;
this.receiveBox.Select(startIndex, message.Length);
this.receiveBox.SelectionColor = Color.Blue;
this.receiveBox.SelectionFont = new Font( "Arial ", 12);

望好心人指教,多谢多谢!


[解决办法]
this.receiveBox.AppendText(message + Environment.NewLine);

读书人网 >C#

热点推荐