MSHFlexGrid多列排序
发布时间:2020-12-15 03:40:57 所属栏目:百科 来源:网络整理
导读:Const ASC As Long = 1 Const DESC As Long = -1 Private SortType As Long Private Sub Command1_Click() SortType = ASC Debug.Print Now MSHFlexGrid1.Sort = 9 Debug.Print Now End Sub Private Sub Command2_Click() SortType = DESC MSHFlexGrid1.Sort
Const ASC As Long = 1 Const DESC As Long = -1 Private SortType As Long Private Sub Command1_Click() SortType = ASC Debug.Print Now MSHFlexGrid1.Sort = 9 Debug.Print Now End Sub Private Sub Command2_Click() SortType = DESC MSHFlexGrid1.Sort = 9 End Sub Private Sub Form_Load() Randomize With MSHFlexGrid1 For i = 1 To .Rows - 1 .TextMatrix(i,3) = CStr(i) .TextMatrix(i,1) = Format(Rnd,"0.0") Next End With End Sub Private Sub MSHFlexGrid1_Compare(ByVal Row1 As Long,ByVal Row2 As Long,Cmp As Integer) Dim x1 As Double,x2 As Double,n1 As Long,n2 As Long x1 = CDbl(MSHFlexGrid1.TextMatrix(Row1,1)) x2 = CDbl(MSHFlexGrid1.TextMatrix(Row2,1)) If x1 < x2 Then Cmp = -1 ElseIf x1 > x2 Then Cmp = 1 Else "第一列相等的情况下,按第三列排序 n1 = CLng(MSHFlexGrid1.TextMatrix(Row1,3)) n2 = CLng(MSHFlexGrid1.TextMatrix(Row2,3)) If n1 < n2 Then Cmp = -1 ElseIf n1 > n2 Then Cmp = 1 Else Cmp = 0 End If End If Cmp = Cmp * SortType End Sub (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |