frmPhNo.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 frmPhNo : Form
  13. {
  14. public frmPhNo()
  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. private void frmPhNo_Load(object sender, EventArgs e)
  66. {
  67. }
  68. }
  69. }