RichTextAutoBottom.cs 936 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace UAS_LabelMachine.CustomControl.RichText
  10. {
  11. public partial class RichTextAutoBottom : RichTextBox
  12. {
  13. public RichTextAutoBottom()
  14. {
  15. InitializeComponent();
  16. TextChanged += RichTextBox_TextChange;
  17. }
  18. private void RichTextBox_TextChange(object sender,EventArgs e)
  19. {
  20. SelectionStart = Text.Length;
  21. ScrollToCaret();
  22. }
  23. /// <summary>
  24. /// color设置AppendText的颜色
  25. /// </summary>
  26. /// <param name="str"></param>
  27. /// <param name="color"></param>
  28. public void AppendText(string str,Color color) {
  29. SelectionColor = color;
  30. base.AppendText(str);
  31. }
  32. }
  33. }