PopupTextBox.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Tool;
  11. namespace Core.StlMes.Client.Mcp.VRP
  12. {
  13. public partial class PopupTextBox : FrmBase
  14. {
  15. public string TextInfo
  16. {
  17. get { return txtInfo.Text.Trim(); }
  18. }
  19. private int _maxLength = 0;
  20. public PopupTextBox(string textInfo, int maxLength)
  21. {
  22. InitializeComponent();
  23. _maxLength = maxLength;
  24. this.txtInfo.Text = textInfo;
  25. }
  26. private void btnOk_Click(object sender, EventArgs e)
  27. {
  28. if (UnicodeEncoding.Unicode.GetBytes(this.txtInfo.Text.Trim()).Length > _maxLength)
  29. {
  30. MessageUtil.ShowWarning("输入的文本超出最大字符数限制!");
  31. return;
  32. }
  33. this.DialogResult = DialogResult.OK;
  34. }
  35. private void btnCancel_Click(object sender, EventArgs e)
  36. {
  37. this.DialogResult = DialogResult.Cancel;
  38. }
  39. private void txtInfo_KeyDown(object sender, KeyEventArgs e)
  40. {
  41. if (e.Control)
  42. {
  43. if (e.KeyCode == Keys.A)
  44. {
  45. txtInfo.SelectAll();
  46. }
  47. }
  48. }
  49. }
  50. }