Populate ComboBox from a List [Resolved]

Posted by Akiii under C# on 5/4/2011 | Points: 10 | Views : 17558 | Status : [Member] | Replies : 4
Hi, I have a list...now i want to bind that to a combo box...But i couldn't do it......

List<string> IndiaState = new List<string>();
IndiaState.Add("WB");
IndiaState.Add("Mizoram");
IndiaState.Add("Nagaland");
IndiaState.Add("Karnataka");
IndiaState.Add("Punjab");
IndiaState.Add("UP");

StateCmbbox.DataSource = IndiaState;


the above is my code, please guide me regarding this....!

Thanks and Regards
Akiii




Responses

Posted by: Ndebata on: 5/4/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Take a look at the attached sample.
You have to add an event in countrycombobox
Thanks,
Debata
 Download source file

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

On which event you are setting the data, it should bind and its working for me.

Thanks,
Debata

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 5/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Ndebata....

Okay i am describing you the whole scenario step by step.....

I have a window application.
In that two comboBox's are there....one is countrycmbbox and the other is statecmbbox.
I am populating the countrycmbbox from database via dataset(and its working fine....no problem)
Now i want to select country from the countrycmbbox and it should show me respective states......in the statecmbbox.....

I have those state in the list as the above code shows.....!

Now, how shd i do it......??
I hope you understand.....if any problem let me know.....i will explain again!

Thank you for ur response...
Akiii


Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 5/4/2011 [Member] Bronze | Points: 25

Up
0
Down
hi debata........

Absolutely fantastic..............u made my day.............
the code is working like a breeze..............
I will just have the first combo-box populate from the database.....and the second combo-box i will do in selectedindexchanged and use a list to populate it....

Thank you for ur help....
Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response