• Welcome to Valhalla Legends Archive.
 

Information on Listview

Started by Imperceptus, August 17, 2004, 09:47 AM

Previous topic - Next topic

Imperceptus

While attepting to Improve the speed of how things get done, I recently Found out that if you have a ListView Control with its Sorted value set to true, then every time you add a row ("row if your using report view"), the list view will resort everything based off of last sort & new data.  Not a big problem if for say you had a list of people in a channel and you were sorting by some flag.  Major problem if you are Sorting a rather large amount of data (in this case more then 1300 rows ).   I am currently disabling the sorted.true option while adding more data to the ListView.   You can also set the visible property of the listview to false to improve update time.

Code for Sorting Rows when ListView.View = 3 - lvwReport

Public Sub SortList(ctlListView As ListView, intColulunHeaderIndex As Integer, Optional Ascending As Boolean, Optional Descending As Boolean)
ctlListView.Refresh
DoEvents
   ctlListView.Sorted = True
   ctlListView.SortKey = intColulunHeaderIndex
   If Ascending = True Then
       ctlListView.SortOrder = lvwAscending
   ElseIf Descending = True Then
       ctlListView.SortOrder = lvwDescending
   Else
       If ctlListView.SortOrder = lvwAscending Then
           ctlListView.SortOrder = lvwDescending
        Else
           ctlListView.SortOrder = lvwAscending
       End If
   End If
   DoEvents
   ctlListView.Refresh
End Sub


Just thought I would post the information to inform others that might need to know at some point or another.

Fixed - Spelling Error
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.