|
-
Dec 3rd, 2004, 05:48 PM
#1
Listview sorting *Resolved*
I found some code from kleinma (I think) for sorting a listview... Here is part of the code :
Code:
Private Sub lvDisks_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Call ClearHeaderIcons(ColumnHeader.Index)
Select Case ColumnHeader.Index
Case 2, 3, 5, 6, 7, 9, 10, 11, 12, 13
Select Case ColumnHeader.Icon
Case "down"
ColumnHeader.Icon = "up"
Call SortColumn(lvDisks, ColumnHeader.Index, sortDescending, sortString)
Case "up"
ColumnHeader.Icon = "down"
Call SortColumn(lvDisks, ColumnHeader.Index, sortAscending, sortString)
Case Else
ColumnHeader.Icon = "down"
Call SortColumn(lvDisks, ColumnHeader.Index, sortAscending, sortString)
End Select
Case 1, 4, 8
Select Case ColumnHeader.Icon
Case "down"
ColumnHeader.Icon = "up"
Call SortColumn(lvDisks, ColumnHeader.Index, sortDescending, sortNumber)
Case "up"
ColumnHeader.Icon = "down"
Call SortColumn(lvDisks, ColumnHeader.Index, sortAscending, sortNumber)
Case Else
ColumnHeader.Icon = "down"
Call SortColumn(lvDisks, ColumnHeader.Index, sortAscending, sortNumber)
End Select
End Select
Set SortIndex = ColumnHeader
End Sub
This works just fine, but that is when the user clicks on a column. How would I sort on form_load though? I tried calling the sub, but I couldn't get it to work. Any ideas?
Last edited by manavo11; Dec 3rd, 2004 at 07:54 PM.
Reason: Resolved
Has someone helped you? Then you can Rate their helpful post. 
-
Dec 3rd, 2004, 06:38 PM
#2
Re: Listview sorting
You called it like this and it didnt work?
Code:
lvDisks_ColumnClick 2
Maybe you can only sort when the lv is finished loading, like in another event,
Form_Activate? Then disable it after first sort so it doesnt keep firing
everytime its activated. Or maybe use a timer so it fires after 250 ms after
its loaded?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 3rd, 2004, 06:49 PM
#3
-
Dec 3rd, 2004, 07:02 PM
#4
Re: Listview sorting
Set a reference to a ColumnHeader and pass that to the event.
Code:
Dim oColumnHeader As MSComctlLib.ColumnHeader
Set oColumnHeader = ListView1.ColumnHeaders(2)
Call ListView1_ColumnClick(oColumnHeader)
Set oColumnHeader = Nothing
-
Dec 3rd, 2004, 07:18 PM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|