开发者

Changes to one TextBox also automatically affects another TextBox

开发者 https://www.devze.com 2023-01-07 06:20 出处:网络
How开发者_运维问答 can I have it so that when changes are made to textbox1 changes will also occur in textbox2?How about:

How开发者_运维问答 can I have it so that when changes are made to textbox1 changes will also occur in textbox2?


How about:

textbox1.TextChanged += delegate { textbox2.Text = textbox1.Text };

If that doesn't help you, please give more information.


You want to add an event handler to textBox1. Double-click on it in the designer: you're now looking at code that will be executed when the text of that textbox changes.

Now type:

textBox2.Text = textBox1.Text;

So as you can probably see, when textBox1 changes, the Text of it (value of the Text property) will be transferred to the Text of textBox2.

Hope that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消