123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.ComponentModel;
- using System.Runtime.InteropServices;
- namespace LYFZ.ComponentLibrary
- {
-
- public class RichTextBoxEx : System.Windows.Forms.RichTextBox
- {
- public RichTextBoxEx() {
-
- }
- /// <summary>
- /// 添加指定颜色的文字到文本框对象
- /// </summary>
- /// <param name="text">要添加的文本</param>
- /// <param name="color">指定的颜色</param>
- public void AppendText(string text,Color color)
- {
- this.SelectionStart = this.TextLength;
- this.SelectionColor = color;
- this.AppendText(text);
-
- }
- /// <summary>
- /// 添加一行指定颜色的文字到文本框对象
- /// </summary>
- /// <param name="text">要添加的文本</param>
- /// <param name="color">指定的颜色</param>
- public void AppendLineText(string text, Color color)
- {
- if (this.TextLength > 0)
- this.AppendText("\r\n" + text, color);
- else
- this.AppendText(text, color);
-
- }
- }
- }
|