EnterTextBox.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 EnterTextBox()
  58. {
  59. InitializeComponent();
  60. this.KeyDown += EnterTextBox_KeyDown;
  61. }
  62. private void EnterTextBox_Enter(object sender, EventArgs e)
  63. {
  64. this.BackColor = Color.GreenYellow;
  65. }
  66. private void EnterTextBox_Leave(object sender, EventArgs e)
  67. {
  68. this.BackColor = Color.White;
  69. }
  70. //手动添加全选功能
  71. private void EnterTextBox_KeyDown(object sender, KeyEventArgs e)
  72. {
  73. if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.A) {
  74. this.SelectAll();
  75. }
  76. }
  77. }
  78. }