Currently I have a collection that stores an ID and value for a certain object. So in the table I've got something like this
EmployeeID | EmployeeName | EmployeeDisplayOrder
1 Simon 4
2 Dean 3
3 Michael 1
4 Andy 2
etc....
for reasons beyond the scope of this question these rows are loaded in to a Generic SortedList using code like this:
Dim MyCol As New Collections.Generic.Sorted
List(Of String, String)
MyCol.Add(1, "Simon")
MyCol.Add(2, "Dean")
MyCol.Add(3, "Michael")
MyCol.Add(4, "Andy")
This collection is used to populate a combobox using a for each loop:
For Each s As String In MyCollection.Values
ComboBox.Items.Add(s)
Next
Now the problem is that I need the items in the collection to appear in the order as defined by EmployeeDisplayOrder in the original table. I don't know how best to tweak what I'm doing in order to end up with something that still has the functionality of a sorted list, but with the ability to have the items in the list sorted by EmployeeDisplayOrder when populating controls with them. Any ideas??
Start Free Trial