MSHFlexGrid 参考两列以上进行排序,如何排?类似Excel里排序的主要关键字、次要关键字

解决方案 »

  1.   

    '排序函數
    Public Sub Sort(sgrd As MSHFlexGrid, Y As Single)
        With sgrd
            If Y < sgrd.CellHeight Then
                If Right(.TextMatrix(0, .Col), 1) = STR_SORT_ASC Then
                    .Sort = flexSortGenericAscending
                    .TextMatrix(0, .Col) = Replace(.TextMatrix(0, .Col), STR_SORT_ASC, STR_SORT_DESC)
                ElseIf Right(.TextMatrix(0, .Col), 1) = STR_SORT_DESC Then
                    .Sort = flexSortGenericDescending
                    .TextMatrix(0, .Col) = Replace(.TextMatrix(0, .Col), STR_SORT_DESC, STR_SORT_ASC)
                Else
                    .Sort = flexSortGenericDescending
                    .TextMatrix(0, .Col) = .TextMatrix(0, .Col) & STR_SORT_ASC
                End If
                .Tag = .Col
            End If
        End With
    End Sub
      

  2.   

    两列以上的排序就要自己写算法了,但是针对GRID排序,读取数据再写入数据会浪费很多时间,效率不高, 所以还是先在数据库里面排好序再输出到grid吧