Results 1 to 3 of 3

Thread: Invert Listbox Items

  1. #1

    Thread Starter
    New Member Patikol's Avatar
    Join Date
    Apr 2015
    Posts
    5

    Question Invert Listbox Items

    Hello people,

    I have a listbox and I want to invert the items in it (reverse them, the first goes last and the last goes first).

    Any short ways to do it?

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,715

    Re: Invert Listbox Items

    Voila:
    Code:
    Dim reversed As IEnumerable(Of String) = ListBox1.Items.Cast(Of String).Reverse
    ListBox1.DataSource = reversed.ToArray
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    New Member Patikol's Avatar
    Join Date
    Apr 2015
    Posts
    5

    Re: Invert Listbox Items

    Quote Originally Posted by dday9 View Post
    Voila:
    Code:
    Dim reversed As IEnumerable(Of String) = ListBox1.Items.Cast(Of String).Reverse
    ListBox1.DataSource = reversed.ToArray
    Awesome, thanks!

Tags for this Thread

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