简体   繁体   中英

Entring same text to all textboxes while writing in one textbox

How can I have the same text being entered in a text box to some other textboxes? I mean when I am typing in a textbox, the same string should go inside other textboxes on the fly!

Which event should be used in this case?

You can use TextChanged event. This event raises whenever there is a change in content of TextBox . You will have to handle it in all the textboxes . If there is any change in one copy this change to all but it is an ugly solution.

Also take a look at how Bindings work. It will be a much cleaner solution. Bind all the textboxes to a single variable . When the value in one textbox will change the associated variable will change and hence value in all the textboxes will change

TextChanged event.

private void currencyTextBox_TextChanged(object sender, EventArgs e)
{
  textbox1.Text = currencyTextBox.Text;
  textbox2.Text = currencyTextBox.Text;
  textbox3.Text = currencyTextBox.Text;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM