Author Topic: VB6 ListBox.Sorted True-False  (Read 7137 times)

0 Members and 1 Guest are viewing this topic.

NYacad

  • Guest
VB6 ListBox.Sorted True-False
« 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

Humbertogo

  • Guest
Re: VB6 ListBox.Sorted True-False
« Reply #1 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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: VB6 ListBox.Sorted True-False
« Reply #2 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie