Skip to content


ComboBox Sorting Defect!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Oops! Never expected this behavior from such a standard control: Winforms ComboBox.

One of the common things our applications require is bind a data source with Collection-base UI elements like ComboBox. The best code any one could write would be: 

cmbTest.DisplayMember = "Name";
cmbTest.ValueMember = "ID";
cmbTest.DataSource = _employeeRecords; 

I would give this a perfect 10!

The combo box displays all the Employee Names in the combo box.  What if you wanted to sort these items?

Let’s use the Sorted property of ComboBox.

this.cmbTest.Sorted = true;

Dush!!!  The code stopped working.

You won’t see Employee Names in the combo box any more. What you would come through is items showing the namespace of the object

_employeeRecords

Now did you expect that?


Related Posts:

Posted in C#, Microsoft .NET, Winform.

Tagged with , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.