After binding a list to combobox, its dataSource.Count is 5 but, combobox item count is 0. how can it be?
I'm used to Web programming and this
is in Windows Forms. So no combo.DataBind();
method exists.
The problem here is, I'm trying to set the selected item programmatically. Since I don't see the combo.Items collection filled, I cannot set the desired item.
Update
A total update is needed I guess:
- datasource contains 7 items
- when bound to combobox,
DisplayMember
andValueMember
are appropriately implemented - after databound, through the gui, I can clearly see the 7 items in the combobox
combobox.DataSource.Count = 7
andcombobox.Items.Count = 0
So the problem is here; since after databound no items are there in the ItemCollection of combobox; I cannot search for one to match and set the appropriate one.
Here is a image for better understanding (But I'm pretty sure I'm missing sth simple)
DataTextField
andDataValueField
accordingly? – Andre Calil Aug 6 '12 at 14:22DisplayMember
andValueMember
. What datatype is in DataSource? – Mr47 Aug 6 '12 at 14:29