-1
假设有两行。红线。蓝线。 谁可以帮忙。RichTextBox中的多个文本格式
假设有两行。红线。蓝线。 谁可以帮忙。RichTextBox中的多个文本格式
你可以使用:
void AppendText(RichTextBox box, Color color, string text)
{
int start = box.TextLength;
box.AppendText(text);
int end = box.TextLength;
// Textbox may transform chars, so (end-start) != text.Length
box.Select(start, end - start + 1);
box.SelectionColor = color;
// could set box.SelectionBackColor, box.SelectionFont, etc...
box.SelectionLength = 0; // clear
}
然后
AppendText(rtb, Color.Red, "line1");
AppendText(rtb, Color.Blue, "line2");
我认为你必须表现出一些更多的努力才有人愿意帮助你。你甚至没有说明你的问题。 –
我同意@Felix,无论如何,我想帮助你,因为你是新来的。记得在问这里之前试着写下你的代码,展示你的努力并写出一个清晰而详细的问题。欢迎来到SO。 – Marco
我感到这种奇怪的感觉,这个问题背后有一些深刻的哲学含义。或者也许只是苏斯博士。 – Amy