【求助】关于vsflexGrid的奇怪现象
我在窗体加了一个vsFlexGrid控件,想按照第1列到最后一列,间隔显示颜色,间隔为7,也就是第2列到第8列(col=1~col=7)为白色
第9列到第15列(col=8~col=14)为蓝色
God,竟然按这段写下来,中间都对的,而第一列到第四列一种颜色,后面间隔都正确,高手们给看看,什么问题哦?
Private Sub Form_Load()
sql = "select * from P_SJW"
TempRsSjw.Open Trim(sql), conn, 3, 2
With sjwGrid
.DataMode = flexDMBound
Set .DataSource = TempRsSjw
.FrozenCols = 1
.Editable = flexEDKbdMouse
.ColAlignment(-1) = flexAlignCenterCenter
End With
Dim i As Long
Dim j As Long
Dim k As Long
'----------------------------------------
'定义第一列的颜色
'sjwGrid.Col = 0
'For i = 0 To sjwGrid.Rows - 1
' sjwGrid.Row = i
' sjwGrid.CellBackColor = &H8000000F
'Next
'----------------------------------------
For i = sjwGrid.Cols - 1 To 1 Step -1
k = CLng((i-1) / 7)
sjwGrid.Col = i
For j = 1 To sjwGrid.Rows - 1
sjwGrid.Row = j
If k Mod 2 = 0 Then
sjwGrid.CellBackColor = vbWhite
Else
sjwGrid.CellBackColor = &H80000013
End If
Next
Next
End Sub
忘了放个测试文件上来,大家看看
test.rar
(11.21 KB)
如果打开出错,请大家把vsflexgrid.ocx注册一下,谢谢
[ 本帖最后由 frank_tao78 于 2010-7-22 15:52 编辑 ]