当点击mshflexgrid列头排序,一共有10列,不知道为何点击单价一列就是提示错误,代码如下
Private Sub grdMingxi_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    SUBMSHFgrid_Sort grdMingxi, x, yEnd Sub
Public Sub SUBMSHFgrid_Sort(FLGrid As MSHFlexGrid, x As Single, y As Single)
    Dim dblRowHeight As Double
    Dim dblColWidth As Double
    Dim i As Integer
    Dim AA As Integer
    dblColWidth = 0
    
    With FLGrid
        If .TextMatrix(1, 1) = "" Then Exit Sub        dblRowHeight = .CellHeight        If y <= dblRowHeight Then            .Row = 0            For i = 0 To .Cols - 1                .Col = i
                dblColWidth = dblColWidth + .CellWidth                If dblColWidth > x Then
               .Tag = IIf(Val(.Tag) = 1, 2, 1)
                             
                    
                For j = 1 To .Rows - 1
                        .TextMatrix(j, 1) = j
                    Next j
                    Exit Sub
                End If            Next i            .SelectionMode = flexSelectionByRow
            .FocusRect = flexFocusLight
            .Row = 1
        End If    End With
   End Sub

解决方案 »

  1.   

    当点击mshflexgrid列头排序,一共有10列,不知道为何点击单价一列就是提示错误,左边是树控件,显示的是物品类别,有材料、备件,当选择材料,点击单价这列就没有错误,当选择备件,点击单价一列排序就有错误,当左边树类别为全部时,点击单价列排序也没有错误,不知道为何,代码如下
    Private Sub grdMingxi_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
      SUBMSHFgrid_Sort grdMingxi, x, yEnd Sub
    Public Sub SUBMSHFgrid_Sort(FLGrid As MSHFlexGrid, x As Single, y As Single)
      Dim dblRowHeight As Double
      Dim dblColWidth As Double
      Dim i As Integer
      Dim AA As Integer
      dblColWidth = 0
        
      With FLGrid
      If .TextMatrix(1, 1) = "" Then Exit Sub  dblRowHeight = .CellHeight  If y <= dblRowHeight Then  .Row = 0  For i = 0 To .Cols - 1  .Col = i
      dblColWidth = dblColWidth + .CellWidth  If dblColWidth > x Then
       If Val(.Tag) = 1 Then
              .Sort = flexSortGenericAscending  此处有错误,当点击其它列没有错,唯有单价这列有错误
              .Tag = 2  
        Else
              .Sort = flexSortGenericDescending 此处有错误,当点击其它列没有错,唯有单价这列有错误          .Tag = 1    End If    
      For j = 1 To .Rows - 1
      .TextMatrix(j, 1) = j
      Next j
      Exit Sub
      End If  Next i  .SelectionMode = flexSelectionByRow
      .FocusRect = flexFocusLight
      .Row = 1
      End If  End With
        End Sub