Advertisement

12.23.2006 at 06:34AM PST, ID: 22102303
[x]
Attachment Details

Visual Basic 2005 Collection Sorted List problem

Asked by noel58 in .NET Framework 2.0, Visual Basic Programming, Microsoft Visual Basic.Net

Tags: 2005, collection, basic, list

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.SortedList(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
[+][-]12.23.2006 at 07:34AM PST, ID: 18192020

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2006 at 07:56AM PST, ID: 18192060

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.23.2006 at 09:42AM PST, ID: 18192321

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2006 at 10:42AM PST, ID: 18192465

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.23.2006 at 12:01PM PST, ID: 18192631

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Visual Basic Programming, Microsoft Visual Basic.Net
Tags: 2005, collection, basic, list
Sign Up Now!
Solution Provided By: graye
Participating Experts: 4
Solution Grade: A
 
 
[+][-]12.26.2006 at 07:39PM PST, ID: 18200957

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.27.2006 at 02:28AM PST, ID: 18201690

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32