怎么将MSFlexGrid中指定行显示为指定颜色???

penghongjie 2006-07-19 11:26:57
怎么将MSFlexGrid中指定行显示为指定颜色???
...全文
166 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
of123 2006-07-21
不过你可以写成一个过程:
Public Sub RowColor(fGrid As MSFlexGrid, ByVal Row As Integer, Optional ByVal BackColor As Long, Optional ByVal ForeColor As Long)
Dim oldRow As Integer, oldCol As Integer
Dim bkclr As Long, frclr As Long
Dim i As Integer

bkclr = fGrid.BackColor
frclr = fGrid.ForeColor

If BackColor Then bkclr = BackColor
If ForeColor Then bkclr = ForeColor

oldRow = fGrid.Row
oldCol = fGrid.Col
fGrid.Redraw = False

fGrid.Row = Row
For i = 0 To fGrid.Cols - 1
If i >= fGrid.FixedCols Then
fGrid.Col = i
fGrid.CellBackColor = bkclr
fGrid.CellForeColor = frclr
End If
Next i
fGrid.Col = oldCol
fGrid.Row = oldRow
fGrid.Redraw = True
fGrid.Refresh
End Sub
回复
of123 2006-07-21
必须循环更改该行所有单元格的背景色。
回复
penghongjie 2006-07-21
.CellBackColor 这个方法只是设置某个单元格的颜色
我要将整行变为指定颜色有没有其它方法,必须用循环嘛?
回复
hn123 2006-07-20
Option Explicit

Private Sub Form_Load()
Me.MSHFlexGrid1.Rows = 10
Me.MSHFlexGrid1.Cols = 10
End Sub

Private Sub MSHFlexGrid1_Click()
Dim i As Integer
Dim j As Integer

Select Case Me.MSHFlexGrid1.Row
Case 1
For j = 1 To Me.MSHFlexGrid1.Cols - 1
Me.MSHFlexGrid1.Col = j
MSHFlexGrid1.CellBackColor = vbRed
Next
Case 2
For j = 1 To Me.MSHFlexGrid1.Cols - 1
Me.MSHFlexGrid1.Col = j
Me.MSHFlexGrid1.CellBackColor = vbGreen
Next
End Select

End Sub
回复
hanstins 2006-07-20
MSFlexGrid1.CellBackColor
当前单元格颜色背景色
回复
发帖
控件
创建于2007-09-28

1425

社区成员

VB 控件
申请成为版主
帖子事件
创建了帖子
2006-07-19 11:26
社区公告
暂无公告