SortDescription sd = new SortDescription("Content", ListSortDirection.Ascending); comboBox1.Items.SortDescriptions.Add(sd);
Sorting Combobox Items Alphabetically
To sort a collection of items inside a combobox alphabetically, one way to do it would be to use the SortDescription class. For this, first you need to add the System.ComponentModel namespace. Then initialize a new SortDescription class in which you can tell by what and how to arrange the list. And finally simply add the class to the combobox you wish to be arranged. In case you want to arrange a simple combobox (only one thing to arrange it by) use the "Content" string when initializing the class as shown in the example bellow:
Subscribe to:
Post Comments (Atom)
SortDescription isn't a class, it's a struct.
ReplyDeleteThe ComboBox Control allows users easily search and select data from multiple column list
ReplyDeleteNot working
ReplyDeletenot working
ReplyDeleteWorking with multi-column ComboBox control
ReplyDelete