MaCodeTextBox.cs 1.9 KB

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