'Make Form2 label text value change by combobox and update exactly when combobox was updated

In Form2

  • I set a public static string to form2text
  • then I set label text value equal to form2text

In Form1

  • under comboBox1_SelectedIndexChanged: Form2.form2text = comboBox1.Text;

How do I get this label to update exactly when the combo box was changed, rather then having to click on label every time I want it to update?

I don't want to open Form2 every time the combo box has been changed.

I want it update inside of Form2.



Solution 1:[1]

after lots of testing I found certain variations simply would not work in the way I wanted (that being the second form closing and re-opening every time I changed a value). I originally used a string with a timer to update that string but as we both know that's extremely inefficient so here is the answer:

 Form2 f2 = new Form2(); // set the name for your second form
f2.label1.Text = Combobox.Text; // make Form2 equal what you want I used combobox

Make sure you set the Modifiers to Public in your Properties Section.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James L