frmQjNo.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  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 frmQjNo : Form
  13. {
  14. public frmQjNo()
  15. {
  16. InitializeComponent();
  17. }
  18. public string strValue = "";
  19. private void btnValue_Click(object sender, EventArgs e)
  20. {
  21. Button btn = (Button)sender;
  22. setTxtValue(btn, 0);
  23. }
  24. private void setTxtValue(Button btn, int m)
  25. {
  26. int i = txtValue.SelectionStart;
  27. txtValue.Focus();
  28. txtValue.Text = txtValue.Text.Trim() + btn.Text;
  29. txtValue.Select(++i + m, 0);
  30. }
  31. private void btnClean_Click(object sender, EventArgs e)
  32. {
  33. txtValue.Text = "";
  34. }
  35. private void btnLeft_Click(object sender, EventArgs e)
  36. {
  37. int i = txtValue.SelectionStart;
  38. txtValue.Focus();
  39. if (i > 0)
  40. txtValue.Select(--i, 0);
  41. }
  42. private void btnRight_Click(object sender, EventArgs e)
  43. {
  44. int i = txtValue.SelectionStart;
  45. txtValue.Focus();
  46. if (i < txtValue.Text.Trim().Length)
  47. txtValue.Select(++i, 0);
  48. }
  49. private void btnBack_Click(object sender, EventArgs e)
  50. {
  51. int i = txtValue.SelectionStart;
  52. txtValue.Focus();
  53. if (i > 0)
  54. {
  55. txtValue.Text = txtValue.Text.Trim().Substring(0, i - 1) + txtValue.Text.Trim().Substring(i);
  56. txtValue.Select(--i, 0);
  57. }
  58. }
  59. private void btnSubmit_Click(object sender, EventArgs e)
  60. {
  61. strValue = txtValue.Text.Trim();
  62. this.DialogResult = DialogResult.OK;
  63. this.Close();
  64. }
  65. }
  66. }