首页 > 代码库 > winfrom RichTextBox每行字体的颜色

winfrom RichTextBox每行字体的颜色

public static void AppendTextColorful(this RichTextBox rtBox, string text, Color color, bool addNewLine = true)
       {
           if (addNewLine)
           {
               text += Environment.NewLine;
           }
           rtBox.SelectionStart = rtBox.TextLength;
           rtBox.SelectionLength = 0;
           rtBox.SelectionColor = color;
           rtBox.AppendText(text);
           rtBox.SelectionColor = rtBox.ForeColor;
       }

winfrom RichTextBox每行字体的颜色