Column sorting in ListView
ello.
i'm using a ListView control and i've pretty much got it sussed apart from the sorting bit. i've got the sorting working no problem, but in a lot of programs the sort buttons (columnHeaders) have these little embedded arrows on them indicating which way the column is sorted in...
how do i do that??
If dog = cat then does a sheep = giraffe?
Errrr...nope, u can't do that with a listview I am afraid :(
U will start to come across the limitations of microsofts controls.
That's why there is a huge marget for creating custom controls out there :D
Also, the sorting only sorts on strings :mad:
If you have the following in a column :
10
34
1
4
2
5
21
and click on the columnheader to sort it, you will get:
1
10
2
21
34
4
5
:mad:
Booooooooooooooooooooooooooo
I have a module with some lovely API commands in it if you want?
It has some public functions in there and to sort on a column u use:
VB Code:
ListViewSortOnDate lvwListView, ColumnHeader.Index
ListViewSortOnString lvwListView, ColumnHeader.Index
ListViewSortOnLong lvwListView, ColumnHeader.Index
Although I have found a problem with this recently as when u sort, lvwListview.SelectedItem points at another item :(
My house is on fire...At least I'll be warm...
Sorry, u mean text allignment...
VB Code:
lvwListView.ColumnHeaders.Add , "MODULE", "Module", 1900, lvwColumnLeft
U can have the following for columnheader allignment
- 0 - lvwColumnLeft
- 1 - lvwColumnRight
- 2 - lvwColumnCenter
But u can't allign the icon! it just sits there :(
Arse sticks and candle, my fone is poo...
Did u ever have a look at the S-Grid on vbAccelerator?
Stuffs the listview into the ground :)
U can do everything with that grid, and it's free...
I laf at your capacity to conduct gamma rays!
Hahahahaha...U r now realising the mistake of using a listview :)
The 1st column ALWAYS has to be Left alligned...Hahahaha.
Watch out for SubItems and ListSubItems :D
Each ListItem can have many ListSubItems, one for each column...Hahahaha. Gets messy :D
ListSubItems are the OBJECT equivalent of SubItems.
You can change color, icons, font, etc, whereas with SubItems u can't...The reason SubItems are there is coz that's how it was 1st designed and they had to keep it in there to support older apps which used it :D
Sorry :(
It's only a matter of time before I nack someone at footy.
On this planet the sky is made of things like paper...