private void button_close_Click(object sender, EventArgs e) { this.Textbox_display.Text = ""; //清除关闭和Enter按钮的焦点,避免影响扫码枪的无意输出 Textbox_display.Focus(); this.Hide(); }
private void button_enter_Click(object sender, EventArgs e) { try { //定义特殊的输入框名称数组(产线、用户名、密码、接箍编号、炉号、批号、机床号) string[] filterArr = { "txtProductionArea", "txtLoginName", "txtLoginPwd", "txtCoupingNo", "txtHeatNo", "txtBatchNo", "txtMachineNo" }; if (inputTxt != null) { inputTxt.Text = Textbox_display.Text; this.Textbox_display.Text = ""; //如果此时获取焦点的输入框的名称在数组中,则点击Enter后隐藏输入法 if (filterArr.Contains(inputTxt.Name)) { Textbox_display.Focus(); //重置焦点 ThreadingForm.getMyForm().btnNone_Click(null, null); this.Hide(); //此处是否要return?? return; } } //查询鼠标焦点所在的TextBox控件在控件集合中的索引 TextBox tb = null; int index = 0; if (flag == 0) { if (ThreadingForm.flpTabOneTextBoxList != null) { index = ThreadingForm.flpTabOneTextBoxList.IndexOf(inputTxt); if (index != -1) { if (index < ThreadingForm.flpTabOneTextBoxList.Count - 1) { index++; } //设置鼠标焦点在控件集合索引为index的控件上 if (ThreadingForm.flpTabOneTextBoxList.Count > 0) { tb = ThreadingForm.flpTabOneTextBoxList[index]; } } } } else if (flag == 1) { if (DetailForm.flpTabOneTextBoxList != null) { index = DetailForm.flpTabOneTextBoxList.IndexOf(inputTxt); if (index != -1) { if (index < DetailForm.flpTabOneTextBoxList.Count - 1) { index++; } //设置鼠标焦点在控件集合索引为index的控件上 if (DetailForm.flpTabOneTextBoxList.Count > 0) { tb = DetailForm.flpTabOneTextBoxList[index]; } } } } if (tb != null) { tb.Focus(); } } catch (Exception ex) { } finally { //清除关闭和Enter按钮的焦点,避免影响扫码枪的无意输出 Textbox_display.Focus(); } }