35 lines
1002 B
C#
35 lines
1002 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Drawing;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace CircleFriendsTools
|
|||
|
{
|
|||
|
public static class MethodExt
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 文本控件方法扩展
|
|||
|
/// </summary>
|
|||
|
/// <param name="rtBox"></param>
|
|||
|
/// <param name="text">控件内容</param>
|
|||
|
/// <param name="color">显示的颜色</param>
|
|||
|
/// <param name="addNewLine">是否换行</param>
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|