ListView sorting VB4.0

There is a problem with sorting a listview by a date in VB 4.0.  Does anyone know a way to get around the problem or is it best to create a public function that will manually sort them?

(The problem with sorting by date is it seems to be sorting by the text value of the date.  If it is mm/dd/yyyy they will be sorted by position 1)
CBrandnerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
watyConnect With a Mentor Commented:
Put a picturebox picColor on the form and set the following properties:

...Visible=False
...AutoRedraw=True

Then call the following sub:

SetColorbar lstView, picColor

(where lstView is the name of your listview control)

Note: lstView style has to be set to lvwReport!


Public Sub SetColorBar(cListView As ListView, _
                       cColorBar As PictureBox, _
                       Optional lFirstColor As Long = &HE2F1E3, _
                       Optional lSecondColor As Long = vbWindowBackground)

    Dim iLineHeight As Long
    Dim iBarHeight As Long
    Dim lBarWidth As Long
     
    On Error GoTo SetColorBarError
     
    If Not cListView.View = lvwReport Then GoTo SetColorBarError
     
    cListView.PictureAlignment = lvwTile
    cColorBar.Font = cListView.Font
     
    iLineHeight = cColorBar.TextHeight("|") + Screen.TwipsPerPixelY
    'iBarHeight = iLineHeight * 3
    iBarHeight = iLineHeight * 1
    lBarWidth = cListView.Width
     
    cColorBar.Height = iBarHeight * 2
    cColorBar.Width = lBarWidth
     
    cColorBar.Line (0, 0)-(lBarWidth, iBarHeight), lFirstColor, BF
    cColorBar.Line (0, iBarHeight)-(lBarWidth, iBarHeight * 2), lSecondColor, BF
     
    cListView.Picture = cColorBar.Image
    Exit Sub

SetColorBarError:
    cListView.Picture = LoadPicture()
End Sub
0
 
damienmCommented:
It seems that the same thing exists with VB6, I would say you will have to use some sort of function to sort date and then use listview.additem.

If you are getting the values using an SQL query then to sort the values first should be easy.
0
All Courses

From novice to tech pro — start learning today.