Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a small application that Employyee management...
In this application i have to update the three diff Databases using a primary called RefID...
The RefID is at combobox only....In Combobox i am having the RefID list...Basing on the selection of Combobox value..The databases updated...But The database is in another form...I have to pass the selected combobx value to another form....But it doesn't possible...

Please help me...I am trying this from 3 days...

Thanks In advance
Posted

This is trivial. The comobobox has a SelectedText and a SelectedValue property. You can pass these through anywhere you like, or use delegates to hook up two forms so one can call another to get a value from it.
 
Share this answer
 
Comments
Bharath Kumar Gorle 8-Jan-13 5:03am    
Thank you Graus...
Bharath Kumar Gorle 8-Jan-13 5:25am    
Wil you give me that code...

Consider that...
We are having
form1 and form2
form1 is having combobox...The values in combo box are taken from database only.....

we have to take that selectd value to form2.....
Thanks In advance...Waitng for ur reply....
Christian Graus 8-Jan-13 14:11pm    
I am quite accustomed to the many people who appear to be paid to write code, but know so little about programming that they can't work with being told what to do, they need a copy and paste solution. I am at a loss that people can be paid to code who know so little, that they don't even know what's possible. No, I can't give you a copy and paste solution, because I don't know enough about your code to do so. I don't know how form1 and form2 interact, to know which of the two options I presented you should use. If you offered to pay me, I still could not write something I would feel sure you could paste, and it would work.
Bharath Kumar Gorle 9-Jan-13 4:17am    
Thank you...for your suggestion..i am very fresher to the dot net programming..since one month only i am practicing the dot net...So i have asked the code....
Christian Graus 9-Jan-13 4:24am    
One month is long enough for you to have started a class, or spent some time starting on a book. It's not long enough for you to work on employee management programs, or anything else that people will actually use
There are many ways that you can pass data between Forms. You should first consider 'Form' is nothing but a class and if you know how to pass data between the classes then that's it, your done.

These are very basic things you should know before you start coding. You should be strong enough with the basics to become a good programmer otherwise you end up with mess.

To answer your question, you can declare a public variable in your form class to set the Combo Box read value. As Chris mentioned in his comment we dont know how your forms are invoked or when it gets displayed. but the following solution may help you to get going with your problem

Assumptions
You want to pass the combo value before the second form get displayed
C#
Form1_Combo_SelectionChange(sender,eventArgs)
{
  string selectedText = Convert.ToString(myCombo.SelectedItem);
  Form2 secondForm = Form2(selectedText);// while defining Form2 add a new Constructor with string as its parameter;
  secondForm.Show();//or ShowDialog()
}


let me know if you are doing something different.
 
Share this answer
 
Comments
Bharath Kumar Gorle 9-Jan-13 4:50am    
Sir my question is....

form1 is having combobox..having value member displayed from database....
the value member called refid

form2 is having datagrid...when ever we click a button basing on the refid...the id details will be displayed on the form2 DATAGRID....

but in my application updatin of datagrid is not possible...because the combobox.selectedvalue is not coming to form2...why please tell me.....If possible give me the code...

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