Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a button that have a value say "q"..and i have two textboxes say txtfirst and txtsecond...if the focus is on txtfirst,the value should be inserted in txtfirst when i click the button ..if focus is changed to txtsecond,then when i click the button the value should be entered to txtsecond......
private void btnq_Click(object sender, EventArgs e)
        {

            
            txtfirst.Text = btnq.Text;
        }



this is for one textbox....i dont know what to do with two textboxes...plz help
Posted

C#
private void btnq_Click(object sender, EventArgs e)
        {
            if (txtfirst.Focused == true)
            {
                txtfirst.Text = btnq.Text;
            }
            if (txtsecond.Focused == true)
            {
                txtsecond.Text = btnq.Text;
            } 
        }
 
Share this answer
 
Comments
Member 8648589 12-Mar-12 8:08am    
thanx for the code..but still when i click the button the value is not inserting to the textboxs...and focus is becoming false like it is refreshing...
Aniket Yadav 12-Mar-12 8:16am    
yes off course becoz when you click the button the focus is set on the button and will be lost from the textboxes.

What exactly you want to do?

will you explain ur concept to me so that i can help you?
Member 8648589 13-Mar-12 0:49am    
i am creating a small application in windows mobile...i am using .net windows ce device application..i have created a abc keyboard with buttons..and i have two input text boxes in the same form..so if i click the text box,the keyboard will appear and when i click the buttons ,the corresponding text will be inserted into the textbox..so if i click the next textbox,when i click the buttons,the similar text must go to the second textbox....this is what i wanted to do./. ..i have tried every pssible way i know...but its not working..plz help :(
i just assigned a public temp variable to a value say 1,when a particular text box got focus...
 
Share this answer
 

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