dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: ListView sorting

  1. #1
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792

    ListView sorting

    Is it possible to sort a NUMERIC field in a listview? I am getting

    1
    10
    11
    2
    20 etc etc

  2. #2
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817
    I have the same problem where size of the files need to be sorted in ascending or descending order. I get the same problem. I takled to my buddies about it and it looks like just to sort it the way you and I want it, may be a lot of coding so I decided to drop the subject for now. I really cant help you here but to just let you know that it may be a hassle to sort them the way you want it. If you find an easy way tho, please let me know. Thanks a lot.

  3. #3
    Join Date
    May 2002
    Location
    India
    Posts
    4
    In the ListView_ColumnClick

    With ListView
    .SortKey = ColumHeader.Index-1
    .Sorted = True
    .SortOrder = lvwAscending
    .Refresh
    End With

    Will Sort ur Data

    Hope this Helps

  4. #4
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329
    The reason it sorts like that is that alpha-numerically this is correct. In order to sort numerics properly you need to pad them with 0's to a fixed length so that they are represented as

    0000001
    0000010
    0000100
    0001000

    And so on. This will then sort correctly. Usually when I encounter this I place these padded values into a column with width set to zero and use that as the sorting column keeping the display of the real data as it was.
    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  5. #5
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    173

    Smile

    Hi Tim,

    You might consider enclosing the URL in your sig in [url] tags. I was curious about the link but I had to go through the long, tedious, burdonsome, labor-intensive task of highlighting the url and, using only my thumb, dragging it all the way to the toolbar.

    pjp
    (specializing in .NET development and hyperbole)
    Preston Park
    CTT+, MCT, MCSD
    http://www.prestonpark.com/

  6. #6
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Thanks for the replies ppl - unfortunately I can't pad with zeros ("too ugly" says the application owner), so I'm just hitting the database again each time they want to sort it. I've altered the stored proc to accept another parameter (sort_order) which orders the results in either asc or desc order depending on what the parameter is.

    Tim - MSDN says that the listview WILL sort numerically - unfortunately what MSDN forgot, was that a listview.listitems(0).text is ..........text. So, yes, you're quite correct, and wonder of wonders, MSDN is wr...wr...wr...dammit, I can't say that word!

    Beeps - the prob was not that I couldnt' sort it, it was that I couldn't sort numerically.

    Thanks again to all.

  7. #7
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210
    The reason you are getting undesireable results is because the data in the Listview is string data and the Listview sorting method will process a string from Left to right rather that numerical value. It does not discriminate between String data vs String data that contains only numeric data.
    There are many samples of how to over come this problem out there on the great WEB
    Try
    Planet-Source-Code.com/vb
    Freebvcode.com
    Mvps.org
    ProgrammersHeaven.com
    VB-Helper.com
    '
    AS an alternative, I offer this sample. It is quite large so bear with me. ALSO this sample is to large for one posting. We are limited to 10000 characters so I will complete it in a follow on post.
    '
    1. Start a new project
    2. Add a listview control and a command button.
    3. Add a module (.bas)
    4. Add a Class module (.cls) and name it cListViewSort
    5. Below is the code for the first two of these modules. Paste it in the appropriate modules
    5.5 See my second reply for the class module code.
    6. Run the program and punch the button to load random data.
    7. Click the column headers to get things sorted the way you want them.
    '
    ' Add this code to the Form
    '
    'frmMyForm
    Option Explicit
    Private mobjListview As cListViewSort
    Private Sub Load()
    Dim NX As ListItem, i As Integer
    Dim Temp As String
    lv.ListItems.Clear
    lv.ColumnHeaders.Clear
    lv.ColumnHeaders.Add , "Hidden", "String", 0, lvwColumnLeft
    lv.ColumnHeaders.Add , "String", "String", 1000, lvwColumnRight
    lv.ColumnHeaders.Add , "Number", "Number", 2000, lvwColumnRight
    lv.View = lvwReport
    For i = 0 To 100
    Temp = String(25, " ")
    RSet Temp = Format(GetRandomNumber, "###,###,###.#0")
    Set NX = lv.ListItems.Add(, "A" & Chr(i), i)
    NX.SubItems(1) = GetRandomNumber
    NX.SubItems(2) = Temp
    Next i
    Set mobjListview = New cListViewSort
    Set mobjListview.ListView = lv
    End Sub

    Private Sub Form_Load()
    Command1.Caption = "Click Here"
    End Sub

    Private Sub lv_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    mobjListview.HandleColumnClick ColumnHeader
    End Sub



    Public Function GetRandomNumber()
    Randomize
    GetRandomNumber = Int((99999 - 1 + 1) * Rnd + 1)
    End Function


    Private Sub Command1_Click()
    lv.ListItems.Clear
    Load
    End Sub
    '
    '
    ' Add this code to the Module
    '
    'Option Explicit

    Public Column As Integer
    Public sOrder As Boolean

    Public objFind As LV_FINDINFO
    Public objItem As LV_ITEM

    Public Type POINT
    x As Long
    y As Long
    End Type


    Public Type LV_FINDINFO
    flags As Long
    psz As String
    lParam As Long
    pt As POINT
    vkDirection As Long
    End Type

    Public Type LV_ITEM
    mask As Long
    iItem As Long
    iSubItem As Long
    state As Long
    stateMask As Long
    pszText As String
    cchTextMax As Long
    iImage As Long
    lParam As Long
    iIndent As Long
    End Type

    'Constants
    Public Const LVFI_PARAM = 1
    Public Const LVIF_TEXT = &H1

    Public Const LVM_FIRST = &H1000
    Public Const LVM_FINDITEM = LVM_FIRST + 13
    Public Const LVM_GETITEMTEXT = LVM_FIRST + 45
    Public Const LVM_SORTITEMS = LVM_FIRST + 48

    'API declarations
    Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long

    Public Declare Function SendMessageAny Lib "user32" Alias "SendMessageA" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long


    Public Function CompareDates(ByVal lParam1 As Long, _
    ByVal lParam2 As Long, _
    ByVal hWnd As Long) As Long

    'CompareDates: This is the sorting routine that gets passed to the
    'ListView control to provide the comparison test for date values.

    'Compare returns:
    ' 0 = Less Than
    ' 1 = Equal
    ' 2 = Greater Than

    Dim dDate1 As Date
    Dim dDate2 As Date

    'Obtain the item names and dates corresponding to the
    'input parameters
    dDate1 = ListView_GetItemDate(hWnd, lParam1)
    dDate2 = ListView_GetItemDate(hWnd, lParam2)

    'based on the Public variable sOrder set in the
    'columnheader click sub, sort the dates appropriately:
    Select Case sOrder
    Case True: 'sort descending

    If dDate1 < dDate2 Then
    CompareDates = 0
    ElseIf dDate1 = dDate2 Then
    CompareDates = 1
    Else: CompareDates = 2
    End If

    Case Else: 'sort ascending

    If dDate1 > dDate2 Then
    CompareDates = 0
    ElseIf dDate1 = dDate2 Then
    CompareDates = 1
    Else: CompareDates = 2
    End If

    End Select

    End Function


    Public Function CompareValues(ByVal lParam1 As Long, _
    ByVal lParam2 As Long, _
    ByVal hWnd As Long) As Long

    'CompareValues: This is the sorting routine that gets passed to the
    'ListView control to provide the comparison test for numeric values.

    'Compare returns:
    ' 0 = Less Than
    ' 1 = Equal
    ' 2 = Greater Than

    Dim val1 As Long
    Dim val2 As Long
    'Obtain the item names and values corresponding
    'to the input parameters
    val1 = ListView_GetItemValueStr(hWnd, lParam1)
    val2 = ListView_GetItemValueStr(hWnd, lParam2)

    'based on the Public variable sOrder set in the
    'columnheader click sub, sort the values appropriately:
    Select Case sOrder
    Case True: 'sort descending

    If val1 < val2 Then
    CompareValues = 0
    ElseIf val1 = val2 Then
    CompareValues = 1
    Else: CompareValues = 2
    End If

    Case Else: 'sort ascending

    If val1 > val2 Then
    CompareValues = 0
    ElseIf val1 = val2 Then
    CompareValues = 1
    Else: CompareValues = 2
    End If

    End Select

    End Function


    Public Function ListView_GetItemDate(hWnd As Long, lParam As Long) As Date

    Dim r As Long
    Dim hIndex As Long

    'Convert the input parameter to an index in the list view
    objFind.flags = LVFI_PARAM
    objFind.lParam = lParam
    hIndex = SendMessageAny(hWnd, LVM_FINDITEM, -1, objFind)

    'Obtain the value of the specified list view item.
    'The objItem.iSubItem member is set to the index
    'of the column that is being retrieved.
    objItem.mask = LVIF_TEXT
    objItem.iSubItem = Column
    objItem.pszText = Space$(32)
    objItem.cchTextMax = Len(objItem.pszText)

    'get the string at subitem 1
    r = SendMessageAny(hWnd, LVM_GETITEMTEXT, hIndex, objItem)

    'and convert it into a date and exit
    If r > 0 Then
    ListView_GetItemDate = CDate(Left$(objItem.pszText, r))
    End If


    End Function


    Public Function ListView_GetItemValueStr(hWnd As Long, lParam As Long) As Long

    Dim r As Long
    Dim hIndex As Long

    'Convert the input parameter to an index in the list view
    objFind.flags = LVFI_PARAM
    objFind.lParam = lParam
    hIndex = SendMessageAny(hWnd, LVM_FINDITEM, -1, objFind)

    'Obtain the value of the specified list view item.
    'The objItem.iSubItem member is set to the index
    'of the column that is being retrieved.
    objItem.mask = LVIF_TEXT
    objItem.iSubItem = Column
    objItem.pszText = Space$(32)
    objItem.cchTextMax = Len(objItem.pszText)

    'get the string at subitem 2
    r = SendMessageAny(hWnd, LVM_GETITEMTEXT, hIndex, objItem)

    'and convert it into a long
    If r > 0 Then
    ListView_GetItemValueStr = CLng(Left$(objItem.pszText, r))
    End If

    End Function

  8. #8
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210
    This is the completion of my previous post
    '
    ' This is the Class module code
    '
    Option Explicit

    'Class CListView



    Private m_ListView As Object
    Private m_fRedraw As Boolean

    Private mflgHeaderDragDrop As Boolean
    Private mflgFlatColumnHeaders As Boolean
    Private mflgSortOrder As Boolean


    Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
    (ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam _
    As Long) As Long

    Private Type POINTAPI
    x As Long
    y As Long
    End Type

    Private Type LV_ITEM
    mask As Long
    iItem As Long
    iSubItem As Long
    state As Long
    stateMask As Long
    pszText As String
    cchTextMax As Long
    iImage As Long
    lParam As Long
    End Type

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

    Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, _
    lpPoint As POINTAPI) As Long

    Private Const LVM_FIRST = &H1000
    Private Const LVM_SETCOLUMNWIDTH = LVM_FIRST + 30
    Private Const LVM_SETITEMSTATE = LVM_FIRST + 43
    Private Const LVM_GETITEMSTATE = LVM_FIRST + 44
    Private Const LVIS_STATEIMAGEMASK = &HF000
    Private Const LVM_GETITEM = LVM_FIRST + 5
    Private Const LVIF_STATE = &H8
    'Private Const LVM_SORTITEMS = (LVM_FIRST + 48)

    Private Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
    Private Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
    Private Const WM_SETREDRAW = &HB
    Private Const LVS_EX_SUBITEMIMAGES = &H2
    Private Const LVS_EX_HEADERDRAGDROP = &H10
    Private Const LVS_EX_FLATSB = &H100

    Private Const LVSCW_AUTOSIZE = -1
    Private Const LVSCW_AUTOSIZE_USEHEADER = -2

    Private Const HDS_BUTTONS = &H2
    Private Const LVM_GETHEADER = (LVM_FIRST + 31)
    Private Const GWL_STYLE = (-16)
    Private Const SWP_DRAWFRAME = &H20
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const SWP_FLAGS = SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME

    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As _
    Long, ByVal cy As Long, ByVal wFlags As Long) As Long

    Public Property Get FlatColumnHeader() As Boolean
    FlatColumnHeader = mflgFlatColumnHeaders
    End Property

    Public Property Let FlatColumnHeader(RHS As Boolean)
    Dim style As Long
    Dim hHeader As Long

    mflgFlatColumnHeaders = RHS

    hHeader = SendMessageLong(m_ListView.hWnd, LVM_GETHEADER, 0, ByVal 0&)
    style = GetWindowLong(hHeader, GWL_STYLE)
    If mflgFlatColumnHeaders Then
    style = style Xor HDS_BUTTONS
    Else
    style = style Or HDS_BUTTONS
    End If

    If style Then
    Call SetWindowLong(hHeader, GWL_STYLE, style)
    End If

    End Property

    Private Sub Class_Terminate()

    Set m_ListView = Nothing

    End Sub

    Public Property Let HeaderDragDrop(bln As Boolean)
    mflgHeaderDragDrop = bln
    SetStyle LVS_EX_HEADERDRAGDROP, mflgHeaderDragDrop
    End Property

    Public Property Get HeaderDragDrop() As Boolean
    HeaderDragDrop = mflgHeaderDragDrop
    End Property

    Private Sub SetStyle(plngStyle As Long, pblnSet As Boolean)
    Dim lngStyle As Long
    Dim lngResult As Long

    On Error GoTo TRAP


    lngStyle = SendMessageLong(m_ListView.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&)

    If pblnSet Then
    lngStyle = lngStyle Or plngStyle
    Else
    lngStyle = lngStyle And (Not plngStyle)
    End If

    lngResult = SendMessageLong(m_ListView.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, lngStyle)

    FUNCTION_EXIT:
    Exit Sub
    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "AllowHeaderDragDrop"
    Resume FUNCTION_EXIT


    End Sub

    Public Property Get ListView() As Object

    Set ListView = m_ListView

    End Property

    Public Property Set ListView(lvwValue As Object)

    On Error GoTo TRAP

    Set m_ListView = lvwValue

    PROP_EXIT:
    Exit Property

    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "ListView"
    Resume PROP_EXIT

    End Property

    Public Property Get Redraw() As Boolean

    Redraw = m_fRedraw

    End Property

    Public Property Let Redraw(ByVal fValue As Boolean)

    m_fRedraw = fValue
    SetRedraw m_fRedraw

    End Property

    Public Sub AutoSizeColumns()
    Dim intColumn As Integer

    On Error GoTo TRAP

    For intColumn = 0 To m_ListView.ColumnHeaders.Count - 1
    If m_ListView.ColumnHeaders(intColumn + 1).Width <> 0 Then
    SendMessageLong _
    m_ListView.hWnd, _
    LVM_SETCOLUMNWIDTH, _
    intColumn, _
    LVSCW_AUTOSIZE_USEHEADER
    End If
    Next intColumn

    SUB_EXIT:
    Exit Sub

    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "AutoSizeColumns"
    Resume SUB_EXIT

    End Sub

    Public Sub AutoSizeColumnsText()
    Dim intColumn As Integer

    On Error GoTo TRAP

    For intColumn = 0 To m_ListView.ColumnHeaders.Count - 1
    If m_ListView.ColumnHeaders(intColumn + 1).Width <> 0 Then
    SendMessageLong _
    m_ListView.hWnd, _
    LVM_SETCOLUMNWIDTH, _
    intColumn, _
    LVSCW_AUTOSIZE
    End If
    Next intColumn

    SUB_EXIT:
    Exit Sub

    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "AutoSizeColumns"
    Resume SUB_EXIT

    End Sub

    Public Sub HandleClick()
    Dim pt As POINTAPI
    Dim liCur As ListItem

    On Error GoTo TRAP

    GetCursorPos pt

    ScreenToClient m_ListView.hWnd, pt

    With m_ListView
    If .ListItems.Count <> 0 Then
    Set liCur = .HitTest(1, Screen.TwipsPerPixelY * pt.y)
    If Not liCur Is Nothing Then
    If Not liCur Is .SelectedItem Then
    Set .SelectedItem = liCur
    SendKeys "{LEFT}"
    End If
    End If
    End If
    End With

    SUB_EXIT:
    Exit Sub
    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "HandleClick"
    Resume SUB_EXIT
    End Sub

    Public Sub HandleColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    Dim intType As Integer
    On Error GoTo TRAP

    mflgSortOrder = Not mflgSortOrder
    sOrder = mflgSortOrder
    Column = ColumnHeader.Index - 1
    m_ListView.SortKey = ColumnHeader.Index - 1

    If m_ListView.ListItems.Count = 0 Then Exit Sub

    intType = 0
    If ColumnHeader.Index = 1 Then
    If IsDate(m_ListView.ListItems(1).Text) Then intType = 1
    If IsNumeric(m_ListView.ListItems(1).Text) Then intType = 2
    Else
    If IsDate(m_ListView.ListItems(1).SubItems(ColumnHeader.Index - 1)) Then intType = 1
    If IsNumeric(m_ListView.ListItems(1).SubItems(ColumnHeader.Index - 1)) Then intType = 2
    If Val(m_ListView.ListItems(1).SubItems(ColumnHeader.Index - 1)) > 0 And _
    InStr(m_ListView.ListItems(1).SubItems(ColumnHeader.Index - 1), "$") > 0 Then _
    intType = 2
    End If

    Select Case intType
    Case 0:
    'Use default sorting to sort the items in the list
    m_ListView.SortOrder = Abs(sOrder) 'Abs(Not m_ListView.SortOrder = 1)
    m_ListView.Sorted = True
    Case 1:
    'Use sort routine to sort by date
    m_ListView.Sorted = False
    SendMessageLong m_ListView.hWnd, _
    LVM_SORTITEMS, _
    m_ListView.hWnd, _
    AddressOf CompareDates
    Case 2:
    'Use sort routine to sort by value
    m_ListView.Sorted = False
    SendMessageLong m_ListView.hWnd, _
    LVM_SORTITEMS, _
    m_ListView.hWnd, _
    AddressOf CompareValues
    End Select
    SUB_EXIT:
    Exit Sub
    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , _
    "HandleColumnClick"
    Resume SUB_EXIT
    End Sub

    Public Sub HideColumn(intColumn As Integer)

    SendMessageLong _
    m_ListView.hWnd, LVM_SETCOLUMNWIDTH, CLng(intColumn), 0

    End Sub

    Private Sub SetRedraw(fDrawOn As Boolean)
    On Error GoTo TRAP

    If Not m_ListView Is Nothing Then
    SendMessageLong m_ListView.hWnd, _
    WM_SETREDRAW, -CLng(fDrawOn), ByVal 0&
    End If
    SUB_EXIT:
    Exit Sub
    TRAP:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , "SetRedraw"
    Resume SUB_EXIT
    End Sub

  9. #9
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792

    Thumbs up

    Thanks John - it shall be used!

    Niall Baird
    Director
    VB Web Solutions

  10. #10
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Couple of things I had to do to get it working...

    Private mobjListview As New CListView
    'instead of
    Private mobjListview As CListView

    ' In the column_click event call it pass the listview into the class module like this

    mobjListview.HandleColumnClick lsvJobs, ColumnHeader

    ' and the function declaration becomes

    Public Sub HandleColumnClick(ByVal pi_lsv As ListView, ByVal ColumnHeader As MSComctlLib.ColumnHeader)


    ' Other than that, it works fantastically!!! I think I'll have to do a little more work on the dates though - they're not working too well at the moment.

  11. #11
    Join Date
    Jul 2002
    Posts
    1
    Here is some code which I found from Microsoft's website:

    'Declare sortColumn in your Form Class
    Dim sortColumn As Integer = -1

    'Create a new class derived from the IComparer class
    Class ListViewItemComparer
    Implements IComparer
    Private col As Integer
    Private order As SortOrder

    Public Sub New()
    col = 0
    order = SortOrder.Ascending
    End Sub

    Public Sub New(ByVal column As Integer, ByVal order As SortOrder)
    col = column
    Me.order = order
    End Sub

    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
    Dim returnVal As Integer
    ' Here is the code for checking dates. I'm sure you could modify this to check for integers as well.
    Try
    Dim firstDate As System.DateTime = DateTime.Parse(CType(x, ListViewItem).SubItems(col).Text)
    Dim secondDate As System.DateTime = DateTime.Parse(CType(y, ListViewItem).SubItems(col).Text)
    returnVal = DateTime.Compare(firstDate, secondDate)
    Catch
    returnVal = [String].Compare(CType(x, ListViewItem).SubItems(col).Text, _
    CType(y, ListViewItem).SubItems(col).Text)
    End Try

    If order = SortOrder.Descending Then
    returnVal *= -1
    End If

    Return returnVal
    End Function
    End Class

    Private Sub lvMain_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles lvMain.ColumnClick

    ' Determine whether the column is the same as the last column clicked
    If e.Column <> sortColumn Then
    sortColumn = e.Column
    lvMain.Sorting = SortOrder.Ascending
    Else
    If lvMain.Sorting = SortOrder.Ascending Then
    lvMain.Sorting = SortOrder.Descending
    Else
    lvMain.Sorting = SortOrder.Ascending
    End If
    End If
    lvMain.Sort()
    lvMain.ListViewItemSorter = New ListViewItemComparer(e.Column, lvMain.Sorting)

    Hope this simplifies things a little for you.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)