sort flag for listview

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Sort flag for Listviewgadget would be nice

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Hello Cor,

I suppose you have processed examples about sorting List gadgets. It is a bit tricky for now but works.

BTW sorting list gadgets is not easy to describe because of multiple columns of listview and listicon, and concerning treegadgets may occur some difficulties also.

Maybe it would be interesting to make a list of detailed features request about this.

ie :

- when you have a list with a given column, you may want to sort it considering strings contained or numerical values ...

- will you accept just a direct / wise order for alphabetical ... with case / nocase flag

- should sorting successively several columns should be hierarchical or not

- is it necessary to have a 'back to initial state' status / flag (which just requires an added hidden column)

Also concerning listview and listicon, some other flags exist through Win API for arranging column display (left aligned, right aligned, ...). This in some cases can be combined with sorting work (does the sort have to consider a left / right align with leading spaces ... ?).

I just develop this here because when I use list gadgets I often work on such sorting stuff with many of questions mentioned above to answer first.

Would be interesting to discuss maybe ?

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Francois,

I now copy the Items of a listbox first to an array-> sort it and then
put that array into the listbox, thats the way I do it.



Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

...,

OK. But do you use API or if not do you want to get some help about ? They are many possibilities using it.

So the first feature request we could make to Fred would be something like :

SortGadget(#Gadget, #PB_Gadget_Sort, param1, param2)

Something like this would apply to gadgets corresponding to lists.

The param1 value would apply to the sort order (direct / reverse) and param2 to a given column if available.

I suppose this would be enough to start.

In the meanwhile, if you need to know 'how to do' using API I can provide you examples.

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

No problem with API, just want a simple sorting. (ASCending of strings)

If there a simple API for like sendmessage (hndl,LV_SORT,0,0)
then I'am happy.

The following is what I use, just a listbox with 1 column

Code: Select all

; Load into array
  For i = 0 To #totalchords
    ChordDicTmp(i)= ChordDic(i,0)
  Next i
;
; Do sorting
SortArray(ChordDicTmp(),0,0,#totalchords)

; Add to Listview
ListViewGadget(1, 82, 30, 120, 160)
  For i= 0 To #totalchords
   AddGadgetItem(1, -1, ChordDicTmp(i))
  Next i

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by El_Choni.

Hi,

I remember posting an example of a sortable ListView gadget, using the method explained in the Win32 API reference. I think it would be easy to implement it as native in PB with just a flag.

Just a thought, bye,

El_Choni
Post Reply