Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMBOBOX DESCENDING SORTING

Status
Not open for further replies.

dalvarezmtz

Programmer
Sep 15, 2004
20
MX
I am actually going nuts about this... i NEED for this to work, now.. im desperate

i cannot figure this stupid thing out...
i want to sort a combobox with certain numbers in a descending way...
i have tried everything including arraylists and nothing seems to work
i am not using any DB, just pure vb.net code.
i get the numbers from a textbox i enter.

PLEASE.. SOME HELP HERE.. PLEASE
 
If is is data-bound, it uses the sort order of that. If not, try setting the Sorted property to False
 
When you submit the number from the text box (hit ok or what not) add the value to an Array List. Then sort the Array List the way you want to with the .Sort method. Then clear the combo box out and loop through the array list in order and add the items to the combo box. There may be a way to do that with out looping also, you may be able to just set the .list or .items equal to the array list.

-Rick

----------------------
 
First, I don't like people reposting 3 times to get there answer but this really works and is the way to go for you.

Code:
Dim d As New DataTable
        Dim c As DataColumn
        Dim r As DataRow
        c = New DataColumn("name", GetType(String))
        d.Columns.Add(c)
        r = d.NewRow
        r.Item(0) = "a"
        d.Rows.Add(r)
        r = d.NewRow
        r.Item(0) = "b"
        d.Rows.Add(r)
        r = d.NewRow
        r.Item(0) = "c"
        d.Rows.Add(r)
        r = d.NewRow
        r.Item(0) = "d"
        d.Rows.Add(r)
        d.DefaultView.Sort = "name DESC"
        ComboBox1.DataSource = d
        ComboBox1.DisplayMember = "name"
        ComboBox1.ValueMember = "name"

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
hehe sorry..
thanks.. worked on it.. and got it done... :)
thanks a lot.
 
NOw tel us what helped you.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
hehe i was working with a listview as well... and i got sorted the listview exactly the way it should be... so i just looped through the listview and filled the combo.. duh...
i was pretty messesd up.. sorry..couldnt think anymore at the time.. :) thanks dudes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top