还是靠自己的努力解决了。哈哈,真是爽啊!
原先的代码有欠考虑。
Private Sub ListView2_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) Dim i% With ListView2 If (ColumnHeader.Index - 1) = .SortKey Then If ColumnHeader.Text = "编号" Then For i = 1 To .ListItems.Count .ListItems(i).Text = Format(.ListItems(i).Text, "000000000000") Next i End If .SortOrder = (.SortOrder + 1) Mod 2 If ColumnHeader.Text = "编号" Then For i = 1 To .ListItems.Count .ListItems(i).Text = Val(.ListItems(i).Text) Next i End If Else If ColumnHeader.Text = "编号" Then For i = 1 To .ListItems.Count .ListItems(i).Text = Format(.ListItems(i).Text, "000000000000") Next i End If .Sorted = False .SortOrder = 0 .SortKey = ColumnHeader.Index - 1 .Sorted = True If ColumnHeader.Text = "编号" Then For i = 1 To .ListItems.Count .ListItems(i).Text = Val(.ListItems(i).Text) Next i End If End If End With End Sub
|