EnterTextBox.cs 2.0 KB

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