可以用.textmatrix(row,col)属性读某行某列的值循环一下就可以找到你要的行了。这是我的设置网络某行颜色的一段代码,只设置灰色和黑色。
Private Sub SetGridLineColor(lLine As Long, Optional Color As Boolean = True)
'Color 为True 时,背景色取反色,否则取黑色
On Error GoTo Err_Handle
Static PreviewLine As Long '前一次置反色的行
Dim i As Long
With grdData
.Redraw = False
.FillStyle = flexFillRepeat
If Color Then
'将前一次置反色的行改回
If PreviewLine <> 0 Then
Call SetGridLineColor(PreviewLine, False)
End If
.Row = lLine
.ColSel = .Cols - 1
' .CellBackColor = &HE0E0E0
' .CellForeColor = vbBlack
.CellBackColor = &H808080
.CellForeColor = vbWhite
Else
If .Rows - 1 < lLine Then
Exit Sub
End If
.Row = lLine
.ColSel = .Cols - 1
' .CellBackColor = vbBlack
' .CellForeColor = vbWhite
.CellBackColor = &HC0C0C0
.CellForeColor = vbBlack
PreviewLine = 0
End If
.Redraw = True
End With
PreviewLine = lLine
Exit Sub
Err_Handle:
End Sub
Private Sub SetGridLineColor(lLine As Long, Optional Color As Boolean = True)
'Color 为True 时,背景色取反色,否则取黑色
On Error GoTo Err_Handle
Static PreviewLine As Long '前一次置反色的行
Dim i As Long
With grdData
.Redraw = False
.FillStyle = flexFillRepeat
If Color Then
'将前一次置反色的行改回
If PreviewLine <> 0 Then
Call SetGridLineColor(PreviewLine, False)
End If
.Row = lLine
.ColSel = .Cols - 1
' .CellBackColor = &HE0E0E0
' .CellForeColor = vbBlack
.CellBackColor = &H808080
.CellForeColor = vbWhite
Else
If .Rows - 1 < lLine Then
Exit Sub
End If
.Row = lLine
.ColSel = .Cols - 1
' .CellBackColor = vbBlack
' .CellForeColor = vbWhite
.CellBackColor = &HC0C0C0
.CellForeColor = vbBlack
PreviewLine = 0
End If
.Redraw = True
End With
PreviewLine = lLine
Exit Sub
Err_Handle:
End Sub
你是在哪個控件上通過的,看那".textmatrix(row,col)"屬性,好象這三個控件都行?
很高興,我加分!
比如:
如果我讓msflexgrid的高度為一次只能顯示10條記錄,
row=20
但我msflexgrid卻不會滾動到指定的位置, 我還是只能看到1--10行.
msdn里明明寫著:object.rowIsvisible(index as long)[=boolean]
到那去看看吧
http://www.csdn.net/expert/topic/194/194844.shtm