MSHFLEXGRID也可以用的哦~ Public Const STR_SORT_ASC = "△" Public Const STR_SORT_DESC = "▽" '//排序函数 Public Sub Sort(sgrd As MSHFlexGrid, y As Single) With sgrd If y >= .RowPos(0) And y < .RowPos(1) Then If .Tag <> "" Then If .Tag <> .Col Then .TextMatrix(0, .Tag) = Left(.TextMatrix(0, .Tag), Len(.TextMatrix(0, .Tag)) - 1) End If End If 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 '//自动调整Grid各列列宽为最合适的宽度 Public Sub AdjustColWidth(frmCur As Form, gridCur As Object, Optional bNullRow As Boolean = True, Optional dblIncWidth As Double = 0) '-------------------------------------------------------------------- '功能: ' 自动调整Grid各列列宽为最合适的宽度 '参数: ' [frmCur]......................当前工作窗体 ' [gridCur].....................当前要调整的Grid '-------------------------------------------------------------------- Dim i, j As Integer Dim dblWidth As Double With gridCur For i = 0 To .Cols - 1 dblWidth = 0 If .ColWidth(i) <> 0 Then For j = 0 To .Rows - 1 If frmCur.TextWidth(.TextMatrix(j, i)) > dblWidth Then dblWidth = frmCur.TextWidth(.TextMatrix(j, i)) End If Next ' .ColWidth(i) = dblWidth + dblIncWidth + 100 End If Next End With End Sub