Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How do you sort integer inside a listbox in desceding order?

thanks.
Posted

1 solution

Don't sort anything in controls like this. Have your data in some suitable collection and sort your data first like in System.Collections.Generic.List<int>.Sort(), using, say (or keep it always sorted like in System.Collections.Generic.SortedList, System.Collections.Generic.SortedDictionary) and then populate the control with data or bind it.

As you need to use custom order in sorting, use this:
http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx[^],
http://msdn.microsoft.com/en-us/library/234b841s.aspx[^].

Code samples are available in the help MSDN articles referenced above.

—SA
 
Share this answer
 
v2
Comments
fjdiewornncalwe 8-Dec-11 14:13pm    
+5. I was thinking the same thing.
Sergey Alexandrovich Kryukov 8-Dec-11 14:21pm    
Sure, we "fools think alike"... :-)
--SA
Sergey Alexandrovich Kryukov 8-Dec-11 14:22pm    
Thank you, Marcus. :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900