Click here to Skip to main content
15,438,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've tried creating a DataTable--and assigning it to the ComboBox's DataSource property, with the DisplayMember and ValueMember both populated. Upon display--data is NOT displayed.

I've tried populating the ComboBox's Items property with the data. Upon display--data is STILL NOT displayed.

I've noticed that Windows Forms is very touchy about this. It's hit or miss.

What's up with this??

What I have tried:

Creating a DataTable and assigning it to the ComboBox's DataSource property;tried Populating the ComboBox's Items property with the data to be displayed;
Updated 27-May-22 4:49am
Richard MacCutchan 27-May-22 10:21am     CRLF
"What's up with this??" Maybe you have done something wrong. However, since we cannot see your code it is impossible to be certain.
Richard MacCutchan 27-May-22 10:50am    
I just ran up a simple example and it works correctly. I also notice that you had a similar issue in your previous question, so how did you resolve that?

1 solution

Start with the debugger.
Look at the datatable and it's content just before you assign it as the DataSource for the Combobox, and check its' Rows and Columns - how many do you have of each? What are the column names (not "I know they are 'X' and 'Y'" - use the debugger and check).
Do those column names match your DisplayMember and ValueMember names exactly (case and spelling!)
If all of that looks right, look at the columns on your data (it may be easiest to assign it as the DataSource for a DGV for this) then sort it by the DisplayMember. Any empty values?

Look for a scroll bar on your ComboBox, check the Type you set it as. Check which ComboBox you are using!

Basically, don't assume anything: check everything. When you find something missing or unexpected, you can start looking at why, and then how to fix it.

But at the moment, we don't have any information to help you fix it, or any way to get that information!
Share this answer

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