NewTextBox.cs 756 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. namespace SmartCoalApplication.Core.CustomControl
  10. {
  11. public partial class NewTextBox : TextBox
  12. {
  13. public NewTextBox()
  14. {
  15. this.TextChanged += new EventHandler(textValueChanged);
  16. }
  17. private void textValueChanged(object sender, EventArgs e)
  18. {
  19. if (this.Text.Contains("|"))
  20. {
  21. MessageBox.Show("'|'為系統使用字符,不可輸入!");
  22. this.Text =this.Text.Replace("|", string.Empty);
  23. return;
  24. }
  25. }
  26. }
  27. }