Moving Text from one form to another

Hi,

try this:

Code:
//Example one
myForm2 form2 = new myForm2();
form2.combobox1.text = this.combobox1.SelectedItem().ToString();
form2.ShowDialog();

//Example two
myForm2 form2 = new myForm2()
form2.stringVarText = this.combobox1.SelectedItem().ToString();
form2.ShowDialog();

In the first example we transferred text from a combobox from the active form to a combobox in a second form. For this to be possible you need to make the combobox in the second form PUBLIC.

In the 2nd example, we simply copied the text from a combobox in the active form to a PUBLIC string variable in the second form, which can then be accessible within the second form at will.

You could also use static variables in a class so they can be accessible from anywhere from your application (I do this a lot).

I hope this helps
 
Back
Top