读书人

VB6.0MSFlexGrid控件单元格颜色设置,该

发布时间: 2012-03-31 13:13:26 作者: rapoo

VB6.0MSFlexGrid控件单元格颜色设置
实现MSFlexGrid控件单数行背景为白色,双数的行背景为蓝色?
Dim i As Integer

With MSFlexGrid1

.AllowBigSelection = True ’ 设置网格样式

.FillStyle = flexFillRepeat

For i = 0 To .Rows 1

.Row = i: .Col = .FixedCols

.ColSel = .Cols() - .FixedCols 1

If i Mod 2 = 0 Then

.CellBackColor = &HC 0C0C0 ’ 浅灰

Else

.CellBackColor = vbBlue ’ 兰色

End If

Next i

End With

以上程序中这段代码是什么意思
For i = 0 To .Rows 1
.Row = i: .Col = .FixedCols
.ColSel = .Cols() - .FixedCols 1


[解决办法]

VB code
Option ExplicitPrivate Sub Form_Load()    Dim intRow  As Integer    Dim intCol As Integer    With MSFlexGrid1        .Rows = 100        .Cols = 8    End With    For intRow = 0 To 99        MSFlexGrid1.Row = intRow        For intCol = 1 To 7            MSFlexGrid1.Col = intCol            If intRow Mod 2 Then                MSFlexGrid1.CellBackColor = RGB(255, 255, 255)            Else                MSFlexGrid1.CellBackColor = RGB(0, 0, 255)            End If        Next intCol    Next intRowEnd Sub 

读书人网 >VB

热点推荐