Results 1 to 4 of 4

Thread: Sort listbox at runtime

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    5

    Post

    I'm able to sort the listbox at design time. But I want it to be done at runtime. If I click a command button it should sort the listbox. When I tried to do "List1.sorted = true" it's coming with an error "Can't assign to read only property". Please help me.

  2. #2
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122

    Post

    Not very sophisticated, but simple and works:

    Have to listboxes, one sorted and not visible, the other not sorted and visible. Add items to both listboxes. When user presses the sort button, clear unsorted (visible) listbox and get the items from the sorted listbox with following code (list1 visible, list2 not and sorted):

    Code:
    Dim i As Long
    
    List1.Clear
    For i = 0 To List2.ListCount - 1
        List1.AddItem List2.List(i)
    Next
    Roger

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Post

    "sorted" is read-only property. What I did is set sorted property to true at design time, then, every time you want to re-sort, just clear list and reload it.

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    5

    Post

    I don't understand why it doesn't support the sorted property during runtime.
    Anyhow thank you Rober for your help.

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