I am working on a WinForms application. There are four text boxes and one button in my form. I am using textBox1.SelectedText += "any string" on a button click so it writes to the first TextBox. If I add textBox1.SelectedText += "any string." then it writes both the textbox1 and textbox 2.
When I click textbox1 and press button then the sting only writes in the first textbox, and I click the second textbox and press the button then it write into second text box .Is there is any way to do this?
I’m using the following code.
private void button1_Click(object sender, EventArgs e)
{
textBox1.SelectedText += "abc";
textBox2.SelectedText += "abc";
}
When I focus on the control, and when we press the button focus goes to the button. So how can we the focus on the one of the text boxes of my form after pressing the button?
You can try this
The idea is that when you enter a textbox, you store it in
selTB.So whan you click button, you know which one textbox was the last selected one.