Click here to Skip to main content
15,886,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this technique to make keyboard
every button of keyboard have this code
C#
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.
Posted
Comments
Mart Rijkers 17-Oct-13 6:47am    
So if you press a key on the keyboard,where is the selection to which textbox it should be writing?
Muhamad Faizan Khan 17-Oct-13 7:16am    
on to a textbox. only one text box
Mart Rijkers 17-Oct-13 7:20am    
You have multiple text boxes. If I type on the keyboard, how to know which textbox to send the text to, of all the boxes you have got?
Muhamad Faizan Khan 17-Oct-13 7:30am    
Focus textbox
BillWoodruff 17-Oct-13 7:22am    
Are you saying that you want to select any one of many TextBoxes to type in, and you want all TextBoxes to display what you type in the selected TextBox ?

1 solution

If you (unlikely) need to update all the textboxes with the same button then list all of them in your handler, e.g
C#
...
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:
C#
...
curSelTextBox.Text += b.Text;
 
Share this answer
 
Comments
Mart Rijkers 17-Oct-13 8:58am    
That is correct. You cannot write to the textbox with focus, since focus is on your keyboard button if it has just been pressed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900