MaCodeTextBox.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using UAS_MES_NEW.PublicMethod;
  5. namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
  6. {
  7. public partial class MaCodeTextBox : TextBox
  8. {
  9. //传值的备用字符串
  10. private string ID1;
  11. private string Power1;
  12. private string str;
  13. private string str1;
  14. private string str2;
  15. /// <summary>
  16. /// 设置锁定字段
  17. /// </summary>
  18. private bool Lock1;
  19. string AllPower1;
  20. public string AllPower
  21. {
  22. get { return AllPower1; }
  23. set { AllPower1 = value; }
  24. }
  25. public string ID
  26. {
  27. get { return ID1; }
  28. set { ID1 = value; }
  29. }
  30. public string Str
  31. {
  32. get { return str; }
  33. set { str = value; }
  34. }
  35. public string Str1
  36. {
  37. get { return str1; }
  38. set { str1 = value; }
  39. }
  40. public string Str2
  41. {
  42. get { return str2; }
  43. set { str2 = value; }
  44. }
  45. public string Power
  46. {
  47. get { return Power1; }
  48. set { Power1 = value; }
  49. }
  50. public bool Lock
  51. {
  52. get { return Lock1; }
  53. set { Lock1 = value; }
  54. }
  55. public MaCodeTextBox()
  56. {
  57. InitializeComponent();
  58. this.KeyDown += MaCodeTextBox_KeyDown;
  59. BackColor = System.Drawing.Color.White;
  60. }
  61. private void EnterTextBox_Enter(object sender, EventArgs e)
  62. {
  63. this.BackColor = Color.GreenYellow;
  64. }
  65. private void EnterTextBox_Leave(object sender, EventArgs e)
  66. {
  67. this.BackColor = Color.White;
  68. }
  69. //手动添加全选功能
  70. private void MaCodeTextBox_KeyDown(object sender, KeyEventArgs e)
  71. {
  72. if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.A)
  73. this.SelectAll();
  74. }
  75. }
  76. }