Unimaginable, stupid bug
Yesterday I had a crazy debugging session on a simple code that just refused to work. I had a listbox which I wanted to databind to a list of objects. I set its DataSource, but the listbox remained empty. So I began thinking and experimenting:
- Maybe the data binding code is somehow wrong? I searched and tried at least four other approaches to databind the list - still empty.
- I added the objects to the listbox items collection one by one (no databinding) - still empty.
- I added a few random strings to the items collection (the simplest case) - still empty.
In desperation I did a little experiment to try to isolate the problem - binding another listbox to another array of object. It worked fine, so I realized that the cause of the problem should be something really stupid. You bet, I was right.
There was another listbox above mine, which I had accidentally added to the form, and it was hiding it completely.
Those evil listbox was never filled with items, so no wonder it was empty. Spending more than an hour on something like this can really be a pain when you you are racing against a deadline, as it was in this case...




0 Comments:
Post a Comment
<< Home