|
2#

楼主 |
发表于 2025-3-15 09:38:50
|
只看该作者
Private Sub 用户_List_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'用户数量在20个时
Dim hoverIndex As Long
Dim hoverValue As String
Dim textheight
textheight = 315 '315为组合框单条文本的高度
' 计算鼠标悬停的选项索引
If Y < textheight Then
hoverIndex = 0
ElseIf Y Mod 300 = 0 Then
hoverIndex = Int(Y / 300) - 1
Else
hoverIndex = Int(Y / 300)
End If
If hoverIndex >= 0 And hoverIndex < Me.用户_List.ListCount Then
' 获取悬停选项的值
hoverValue = Me.用户_List.ItemData(hoverIndex)
' 将值显示在文本框中
Me.txtUser.Value = hoverValue
End If
End Sub |
|