I have a C# form application. I have a hashtable of object (id - title...). I fill the combobox with the id and the title. When someone select an item, i get the id and title, extract the id and get the object from the hashtable.
I use List where I need some sorting.
Is there a better way to do that?
Thanks
You can use SortedDictionary
You can create derived class from 'KeyedCollection' http://msdn.microsoft.com/en-us/library/ms132438.aspx . Let's assume it will contain items of 'SomeItem' class. That class have properties Id, Name and some others. Set this KeyedCollection as ComboBox datasource. Then set ValueMemeber = "Id", DisplayMember = "Name"; After that you can cast "SelectedItem" to 'SomeItem' class and work with it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.