如何才能让MSHFlexGrid表格随鼠标移动而进行变色?

tcrct 2006-02-18 09:10:00
即是像点击菜单时,在菜单上移动是,底下有一条色带跟随着鼠标移动而移动,如果在MSHFlexGrid表格里,应该如何去实现这个功能呢?请指教!
...全文
169 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
faysky2 2006-02-19
  • 打赏
  • 举报
回复
少了一句

Dim cRow As Long, tRow As Long
Dim curRow As Long, tmpRow As Long
Private Sub MSHFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then Exit Sub
With MSHFlexGrid1

If .MouseRow < .FixedRows Then Exit Sub
If curRow <> tmpRow Then
cRow = .MouseRow
.Row = tRow

If .Row <> 0 And .Col <> 0 Then
For i = .FixedCols To .cols - 1
.Col = i
.CellBackColor = .BackColor
Next
End If
.Row = cRow
For i = .FixedCols To .cols - 1
.Col = i
.CellBackColor = vbBlue
Next
.Col = .MouseCol
tmpRow = curRow
Else
tRow = cRow
curRow = .RowPos(.MouseRow) + .CellHeight
End If
End With
End Sub


Free_Windy 2006-02-19
  • 打赏
  • 举报
回复
楼上的思路是可以实现的...
tcrct 2006-02-19
  • 打赏
  • 举报
回复
faysky2():

谢谢!不过按你的方法试了,但结果不理想呀,因为每次移动都到了最后的列和行,不能查看全部数据呀!
faysky2 2006-02-18
  • 打赏
  • 举报
回复
Dim cRow As Long, tRow As Long
Dim curRow As Long, tmpRow As Long
Private Sub MSHFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then Exit Sub
With MSHFlexGrid1

If .MouseRow < .FixedRows Then Exit Sub
If curRow <> tmpRow Then
cRow = .MouseRow
.Row = tRow

If .Row <> 0 And .Col <> 0 Then
For i = .FixedCols To .cols - 1
.Col = i
.CellBackColor = .BackColor
Next
End If
.Row = cRow
For i = .FixedCols To .cols - 1
.Col = i
.CellBackColor = vbBlue
Next
tmpRow = curRow
Else
tRow = cRow
curRow = .RowPos(.MouseRow) + .CellHeight
End If
End With
End Sub
tcrct 2006-02-18
  • 打赏
  • 举报
回复
要求的是整行一起变底色.

2,506

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧