ucCarNoKey.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace MeterModuleLibrary
  11. {
  12. public partial class ucCarNoKey : UserControl
  13. {
  14. public ucCarNoKey()
  15. {
  16. InitializeComponent();
  17. }
  18. public string strValue = "";
  19. private void btnSetValue_Click(object sender, EventArgs e)
  20. {
  21. Button btn = (Button)sender;
  22. int i = txtValue.SelectionStart;
  23. txtValue.Focus();
  24. txtValue.Text = txtValue.Text.Trim() + btn.Text;
  25. txtValue.Select(++i, 0);
  26. }
  27. private void btnProvince_Click(object sender, EventArgs e)
  28. {
  29. Button btn = (Button)sender;
  30. txtProvince.Text = btn.Text;
  31. }
  32. private void btnLeft_Click(object sender, EventArgs e)
  33. {
  34. int i = txtValue.SelectionStart;
  35. txtValue.Focus();
  36. if (i > 0)
  37. txtValue.Select(--i, 0);
  38. }
  39. private void btnRight_Click(object sender, EventArgs e)
  40. {
  41. int i = txtValue.SelectionStart;
  42. txtValue.Focus();
  43. if (i < txtValue.Text.Trim().Length)
  44. txtValue.Select(++i, 0);
  45. }
  46. private void btnBack_Click(object sender, EventArgs e)
  47. {
  48. int i = txtValue.SelectionStart;
  49. txtValue.Focus();
  50. if (i > 0)
  51. {
  52. txtValue.Text = txtValue.Text.Trim().Substring(0, i - 1) + txtValue.Text.Trim().Substring(i);
  53. txtValue.Select(--i, 0);
  54. }
  55. }
  56. private void btnClean_Click(object sender, EventArgs e)
  57. {
  58. txtValue.Text = "";
  59. }
  60. private void btnSubmit_Click(object sender, EventArgs e)
  61. {
  62. strValue = txtValue.Text.Trim();
  63. txtValue.Text = "";
  64. //此处还需调用加载该用户控件的界面关闭方法
  65. }
  66. }
  67. }