using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MeterModuleLibrary { public partial class frmQjNo : Form { public frmQjNo() { InitializeComponent(); } public string strValue = ""; private void btnValue_Click(object sender, EventArgs e) { Button btn = (Button)sender; setTxtValue(btn, 0); } private void setTxtValue(Button btn, int m) { int i = txtValue.SelectionStart; txtValue.Focus(); txtValue.Text = txtValue.Text.Trim() + btn.Text; txtValue.Select(++i + m, 0); } private void btnClean_Click(object sender, EventArgs e) { txtValue.Text = ""; } private void btnLeft_Click(object sender, EventArgs e) { int i = txtValue.SelectionStart; txtValue.Focus(); if (i > 0) txtValue.Select(--i, 0); } private void btnRight_Click(object sender, EventArgs e) { int i = txtValue.SelectionStart; txtValue.Focus(); if (i < txtValue.Text.Trim().Length) txtValue.Select(++i, 0); } private void btnBack_Click(object sender, EventArgs e) { int i = txtValue.SelectionStart; txtValue.Focus(); if (i > 0) { txtValue.Text = txtValue.Text.Trim().Substring(0, i - 1) + txtValue.Text.Trim().Substring(i); txtValue.Select(--i, 0); } } private void btnSubmit_Click(object sender, EventArgs e) { strValue = txtValue.Text.Trim(); this.DialogResult = DialogResult.OK; this.Close(); } } }