新建一个模块,在模块类写一个扩展函数,不知道你用的是什么语言,以vb.net为例:<Extension()> Public Sub AppendRichText(rtb As RichTextBox, text As String, color As System.Drawing.Color, font As System.Drawing.Font) rtb.Select(rtb.TextLength, 0) rtb.SelectionColor = color rtb.SelectionFont = font rtb.AppendText(text) rtb.SelectionColor = rtb.ForeColor rtb.SelectionFont = rtb.Font End Sub
Public Sub AppendRichText(rtb As RichTextBox, text As String, color As System.Drawing.Color, font As System.Drawing.Font)
rtb.Select(rtb.TextLength, 0)
rtb.SelectionColor = color
rtb.SelectionFont = font
rtb.AppendText(text)
rtb.SelectionColor = rtb.ForeColor
rtb.SelectionFont = rtb.Font
End Sub