A
A
Alexander Sharomet2014-03-13 09:46:16
Programming
Alexander Sharomet, 2014-03-13 09:46:16

How to pass data between two textboxes in realtime c#?

Hello.
I have a question. how can you transfer data between two textboxes in real time, that is, you enter text in textbox1, and it is immediately displayed in another textbox2
KeyPress is not suitable, since it only transfers the second press, that is, we write "123" in the other will be " 12"
How to solve this problem?

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
   {
     
       textBox2.Text =textBox1.Text;
     
   }

Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kerman, 2014-03-13
@sharomet

Use the TextChanged event.

C
Codebaker, 2014-03-13
@Codebaker

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            textBox2.Text = textBox1.Text;
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question