469,352 Members | 1,945 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Sort ComboBox

C# .NET 1.1

How do I sort ComboBox in descending order?

Thanks
Peter
Feb 7 '06 #1
4 32047
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi

Feb 7 '06 #2

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.
Feb 7 '06 #3
This is the easiest way if the items implements IComparable (for
example: strings):
ArrayList list = ArrayList.Adapter(comboBox1.Items);
list.Sort();
To reverse, call list.Reverse();

Thi

Peter wrote:
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.


Feb 7 '06 #4

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
This is the easiest way if the items implements IComparable (for
example: strings):
ArrayList list = ArrayList.Adapter(comboBox1.Items);
list.Sort();
To reverse, call list.Reverse();

Thi

Peter wrote:
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
>I think you should sort the items before adding/binding to the
> combobox. For example, you could use Array.Sort, ArrayList.Sort, or
> using DataView if you are binding DataSet to the combobox. There are
> also Array.Reserve and ArrayList.Reserve method for you to change the
> order if neccesary.
>
> Thi
>


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.


Thank You,

works for me.
Feb 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by MrNobody | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.