一个键盘用于多个文本框 [英] One Keyboard for multiple textboxes

查看:66
本文介绍了一个键盘用于多个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这种技术制作键盘

每个键盘按钮都有这个代码

  private   void  button77_Click( object  sender,EventArgs e)
{
按钮b =发件人 as 按钮;
Search_Form.tb.Text + = b.Text;
}





现在问题是我有多个文本框,对于我想要使用的多个文本框唯一一个键盘,但通过上述技术,这是不可能的,因为tb.text只有一个文本框。

如何制作一个Genral键盘,它可以在我想要的所有文本框中工作。

解决方案

如果您(不太可能)需要使用相同的按钮更新所有文本框,请在处理程序中列出所有文本框,例如

 ... 
Search_Form.tb.Text + = b.Text;
Search_Form.tb1.Text + = b.Text;
...



另一方面,如果您只需要更新当前选中的文本框,那么您应该实现一种识别它的机制。例如,您可以为 curSelTextBox 变量分配对获得输入焦点的最后一个文本框的引用。然后,在你的事件处理程序中使用:

 ... 
curSelTextBox.Text + = b.Text;


I am using this technique to make keyboard
every button of keyboard have this code

private void button77_Click(object sender, EventArgs e)
       {
           Button b = sender as Button;
      Search_Form.tb.Text += b.Text;
       }



now the problem is i have mulitple text boxes, For multiple text boxes i want to use the only one keyboard but by above technique it is not possible because tb.text only one textbox.
how to make a Genral keyboard which do work in all my textboxes where i want.

解决方案

If you (unlikely) need to update all the textboxes with the same button then list all of them in your handler, e.g

...
Search_Form.tb.Text += b.Text;
Search_Form.tb1.Text += b.Text; 
...


On the other hand, if you need to update just the 'currently selected' textbox then you should implement a mechanism for identifying it. For instance you might assign to the curSelTextBox variable a reference to the last text box that got the input focus. Then, in your event handler use:

...
curSelTextBox.Text += b.Text;


这篇关于一个键盘用于多个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆