TheSwamp

Code Red => VB(A) => Topic started by: NYacad on May 29, 2007, 09:56:25 AM

Title: VB6 ListBox.Sorted True-False
Post by: NYacad on May 29, 2007, 09:56:25 AM
How to change in VB6 ListBox Sorted property while loading form?

Primitive

Private Sub Form_Initialize()
List1.Sorted = True
End Sub


does not work.
Thank you,
Alex Borodulin
http://www.nyacad.com
alex@nyacad.com
Title: Re: VB6 ListBox.Sorted True-False
Post by: Humbertogo on May 29, 2007, 10:37:28 AM
The sort property of a listbox can only be set at design time. You will need to write your own procedure to sort the listbox.
Title: Re: VB6 ListBox.Sorted True-False
Post by: Keith™ on May 29, 2007, 11:21:42 AM
In VB6 the list sorting happens when the value is changed, not when the list is populated, thus you would need to populate the listbox first, then set the sorting to true.

This is an example of having a multiple column listbox where the column can be sorted by any column, depending upon which column you select.

Code: [Select]
Private Sub listView_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
   
   listView.SortKey = ColumnHeader.Index - 1
   listView.Sorted = True
   
End Sub