EnterTextBox.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace UAS_MES.CustomControl.TextBoxWithIcon
  5. {
  6. public partial class EnterTextBox : TextBox
  7. {
  8. //传值的备用字符串
  9. private string ID1;
  10. private string Power1;
  11. private string str;
  12. private string str1;
  13. private string str2;
  14. string AllPower1;
  15. public string AllPower
  16. {
  17. get
  18. {
  19. return AllPower1;
  20. }
  21. set
  22. {
  23. AllPower1 = value;
  24. }
  25. }
  26. public string ID
  27. {
  28. get
  29. {
  30. return ID1;
  31. }
  32. set
  33. {
  34. ID1 = value;
  35. }
  36. }
  37. public string Str
  38. {
  39. get
  40. {
  41. return str;
  42. }
  43. set
  44. {
  45. str = value;
  46. }
  47. }
  48. public string Str1
  49. {
  50. get
  51. {
  52. return str1;
  53. }
  54. set
  55. {
  56. str1 = value;
  57. }
  58. }
  59. public string Str2
  60. {
  61. get
  62. {
  63. return str2;
  64. }
  65. set
  66. {
  67. str2 = value;
  68. }
  69. }
  70. public string Power
  71. {
  72. get
  73. {
  74. return Power1;
  75. }
  76. set
  77. {
  78. Power1 = value;
  79. }
  80. }
  81. public EnterTextBox()
  82. {
  83. InitializeComponent();
  84. this.KeyDown += EnterTextBox_KeyDown;
  85. BackColor = System.Drawing.Color.White;
  86. }
  87. private void EnterTextBox_Enter(object sender, EventArgs e)
  88. {
  89. this.BackColor = Color.GreenYellow;
  90. }
  91. private void EnterTextBox_Leave(object sender, EventArgs e)
  92. {
  93. this.BackColor = Color.White;
  94. }
  95. //手动添加全选功能
  96. private void EnterTextBox_KeyDown(object sender, KeyEventArgs e)
  97. {
  98. if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.A)
  99. {
  100. this.SelectAll();
  101. }
  102. }
  103. }
  104. }