Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi All,
 
how to pass combobox selected text to another form combobox in windows application.
 
I have 2 forms in windows application Like form1 and form2.
 
In form1 i have one combobox(cbxstate) is there, in form2 same combobox(cbxstate) control is there. If i select any data in form1 combobox that data i want to pass to form2 combobox.
 
is it possible to pass the information?
 
Please help me!
 
Thanks and Regards,
murali.
Posted 31-Aug-12 21:10pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

1.First Set combobox as public of form1
2.Create selectedchanged event of combobox
3In that create object of form2
ex. Form2 f2=new Form2();
3.Assign value of combobox from form1 to form2 combobox
ex. f2.combobox.item.Add(this.combobox.Text);
  Permalink  
Comments
Zoltán Zörgő at 3-Sep-12 15:04pm
   
Well... this was a reformulation of my answer :(
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The simplest, but not too elegant way is to make the combobox on form2 public. Look for the "Modifiers" property in the editor, design folder. But be aware that you can access it only if a form of that class is actually instantiated.
 
The more elegant way is to create a model, and bind the same value to both combo boxes.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I agreed with the solution 1. I would like to add a Plug-Ins to that.
Refer the link below.
Article:
Passing Data Between Forms[^]
 
Similar threads:
Passing variable between winforms[^]
c# winforms - passing string variables between forms[^]
 

--Amit
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi ,
Check this
how to pass values from child form to parent form[^]
Best Regards
M.Mitwalli
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi,
 
Simple create static variable, Assign value in Form1, Go to the Form2 And read static variable value. Thats it!!!! (Only if you do not have any issue with static variableSmile | :) )
 
Thanks
-Amit Gajjar
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 685
1 Manas Bhardwaj 380
2 OriginalGriff 344
3 Abhinav S 293
4 Sampath Lokuge 245
0 Sergey Alexandrovich Kryukov 7,967
1 OriginalGriff 4,332
2 Peter Leow 3,699
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 1 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid