Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

try this:

 

//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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...