Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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
Updated 2-Jun-23 2:59am

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);
 
Share this answer
 
Comments
[no name] 1-Sep-12 5:12am    
Thank you for all , it's working now!!
Zoltán Zörgő 3-Sep-12 15:04pm    
Well... this was a reformulation of my answer :(
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.
 
Share this answer
 
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
 
Share this answer
 
Hi ,
Check this
how to pass values from child form to parent form[^]
Best Regards
M.Mitwalli
 
Share this answer
 
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 variable:))

Thanks
-Amit Gajjar
 
Share this answer
 
I have 2 forms like form1.cs and form2.cs, Now I have to go from form1 to form2 for that I used combobox
on my form1 now i put 2 values form1 and form2 in the combobox when I switch form2 i will redirect to form2 in C# WFA.
 
Share this answer
 
Comments
Richard Deeming 2-Jun-23 9:05am    
Your question is not a "solution" to someone else's question.

If you want to ask a question, then ASK A QUESTION[^]. But you're going to have to provide a lot more information than you have here if you want anyone to be able to help you.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900