Sorting ListViewGadgets
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by blueb.
Hi,
I'm working on getting file names from a directory
with ExamineDirectory command and stuffing the
results into a ListViewGadget.
Everything works well, except the ListViewGadget
does not display the filenames in alphabetical order.
How can I sort the ListViewGadget? Or do I need
to stuff the results in an array first, then
insert the array into the LV?
The AddGadgetItem "position" flag doesn't work here.
Regards,
--blueb
Hi,
I'm working on getting file names from a directory
with ExamineDirectory command and stuffing the
results into a ListViewGadget.
Everything works well, except the ListViewGadget
does not display the filenames in alphabetical order.
How can I sort the ListViewGadget? Or do I need
to stuff the results in an array first, then
insert the array into the LV?
The AddGadgetItem "position" flag doesn't work here.
Regards,
--blueb
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
I think you must sort the array first. If you want to allow the user to sort the list afterwards, check this:
viewtopic.php?t=869
Bye,
El_Choni
I think you must sort the array first. If you want to allow the user to sort the list afterwards, check this:
viewtopic.php?t=869
Bye,
El_Choni
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
You simply create a ListBox with the styles:
#LBS_SORT | #LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS
and for adding new stuff you use:
SendMessage_(handle, #LB_ADDSTRING, 0, String).
cya,
...Danilo
(registered PureBasic user)
You simply create a ListBox with the styles:
#LBS_SORT | #LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS
and for adding new stuff you use:
SendMessage_(handle, #LB_ADDSTRING, 0, String).
Code: Select all
hWnd = OpenWindow(1,100,100,400,300,#PB_Window_SystemMenu,"ListBox Sort")
CreateGadgetList(hWnd)
ListViewGadget(1, 10,10,280,280,#LBS_SORT | #LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS)
StringGadget (2,300,50, 90, 20, "Type here")
ButtonGadget (3,320,75, 50, 20, "Add")
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow: End
Case #PB_EventGadget
Select EventGadgetID()
Case 1 ; ListView
If EventType() = #PB_EventType_LeftDoubleClick
; show the selected listview entry on doubleclick
MessageRequester("INFO",GetGadgetItemText(1,GetGadgetState(1),0),0)
EndIf
Case 3 ; Button: Add
SendMessage_( GadgetID(1), #LB_ADDSTRING, 0, GetGadgetText(2))
EndSelect
EndSelect
ForEver
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Hehe... PB
Look at the code - i use 2, 3 and 4 spaces.
Its my personal coding style:
But now, Fred said i should always use 2 spaces
for indents... so all my personal style got
mixed up - but is still very readable, IMHO.
For me, mostly 3 spaces and TAB set to 8 or 10 is OK.
You´ll see the complete new Editor in few hours
with 3.40...
cya,
...Danilo
(registered PureBasic user)
Hehe... PB
Look at the code - i use 2, 3 and 4 spaces.
Its my personal coding style:
Code: Select all
If x = 1 next line here, 3 spaces
Endif
Case 1
Code here, 5 spaces
Case 2
Code herefor indents... so all my personal style got
mixed up - but is still very readable, IMHO.
For me, mostly 3 spaces and TAB set to 8 or 10 is OK.
You´ll see the complete new Editor in few hours
with 3.40...
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm