|
If I do the combobox databinding during form initialization time (c'tor), things work OK, I see the column I specified in the DisplayMember, and the values are the expected ones. However, I don't always know which table, or even database a user will select at run time, so I want to populate the combobox after it has been displayed on the form empty. Well, databinding AFTER it is shown, does nothing. No data are shown. Same exact code that works during form c'tor time does nothing after the form has been displayed. Spellings etc are all the same, as all is done using the same function. I use a small utility function that creates and populates a dataset and binds it to the combobox.
Now for the interesting part...
If I call this utility once (after combo has been displayed) no data are loaded into the combobox (as mentioned). Then if I call it again...voila! the data are there. Seems some event is not broadcasted when the datasource prop changes from null to something, but it is generated when the datasource is changed to a new object. Obviously in real life I do not want to have to create and populate big datasets twice, just to get around this #$@! combo problem. Any other solutions will be greatly appreciated. I tried binding to a 'fake' empty dataset but then I get the stupid DataViewRow...garbage item in the combobox since the fake empty dataset has no table to bind the DisplayMember to...duh!
TIA!
- erika
ps I'm using WinForms and C# |