Neudesic Blogs

Think Smart. Get Results.
Welcome to Neudesic Blogs Sign in | Join | Help
in Search

Pete Orologas

How to Sort a ListBox

Don't forget to give me a shout out if this helped you!! .... shout out = nice comment :)

 

*****    Helper Method for Sorting ListBoxes     *********

 

private void SortListbox(ListBox box)
{
    SortedList sortedItems = new SortedList();

    for(int i = 0; box.Items.Count - i != 0; i++)
    {
        sortedItems.Add(box.Items[i].Text, box.Items[i].Value);
    }

    if (sortedItems.Count != 0)
    {
        box.Items.Clear();
        box.DataSource = sortedItems;
        box.DataTextField = "key";
        box.DataValueField = "value";
        box.DataBind();
    }
}

Pete Orologas

Published Wednesday, July 19, 2006 12:18 AM by Porologas

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Bill said:

you comment deleting ***.... don't make drive down to your house and kick yur ass on the mame machine again....
July 18, 2006 9:23 PM
 

Anders said:

Thanks! This helped me a lot.

Regards
Anders
November 1, 2006 2:30 AM
 

Dirk said:

Great method. Very useful. Thanks M8.
October 26, 2007 5:08 AM
 

SweHar said:

thanks ..quite useful
January 9, 2008 9:12 PM

What do you think?

(required) 
(optional)
(required) 

This Blog

Post Calendar

<July 2006>
SuMoTuWeThFrSa
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

Syndication

Powered by Community Server, by Telligent Systems