Results 1 to 2 of 2

Thread: sorting data in listbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2008
    Posts
    6

    sorting data in listbox

    i am displaying text in a listbox that i am getting from variables and i want to be able to sort it alphabetically from a-z and z-a by clicking a button but i can find anywhere the code needed to sort the data held in the listbox but all i can do is sort it using the properties but this only sorts it a-z.

    the data in the variables comes from a text file.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sorting data in listbox

    You've got two main choices:

    1. Inherit the ListBox class and override the Sort method, adding functionality to sort in ascending and descending order.

    2. Put your data in an array and bind it to the ListBox. You can then Sort and Reverse the array and rebind it each time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width