msflexgrid每一行显示不同的背景怎么写?

解决方案 »

  1.   

    Option Explicit'    Purpose:
    '     Author:吴文智
    '       Date:2001-11-08
    'Description:要试用本例请在窗体中填加一个MSFlexGrid
    '            然后在代码窗体中粘贴如下代码
    '            Good luck!Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        Dim lngCol As Long
        Dim lngColor As Long
        
        '不能直接完成,要自己模拟
        '如想直接完成的话,请使用ListView或vsFlexGrid
        With MSFlexGrid1
            If Button = vbLeftButton And Shift = vbCtrlMask Then
                .Col = .FixedCols
                If .CellBackColor = vbBlue Then
                    lngColor = vbWhite
                Else
                    lngColor = vbBlue
                End If
                    
                For lngCol = .FixedCols To .Cols - 1
                    .Col = lngCol
                    .CellBackColor = lngColor
                Next
            End If
        End With
    End Sub