注册 登录
编程论坛 VB6论坛

VB VsListView右键菜单 List失去焦点怎么解决

mmy19811217 发布于 2020-11-29 06:18, 2479 次点击
我用VsListView制作的表格,当右击列表时会有弹出菜单,但是焦点却不在List列表上,请大家帮忙看看要怎样弄?注意!!我用的是VsListView控件,不是ListView控件,需要控件的请在下面下载:
https://pan.baidu.com/s/1oZj3BZCqa68W-fCz0HavYw 提取码1qaz
6 回复
#2
cwa99582020-11-29 09:50
你为什么不把你的程序放上呢?
#3
mmy198112172020-11-29 12:10
回复 2楼 cwa9958
下面是VsListView的实例,通过这个实例可以知道VsListView控件的基本操作
https://pan.baidu.com/s/1gRUDlPZnC9uFgM5MzBXi5A 提取码2qaz

下面是我自己写的右键单击代码:
Private Sub vsListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

    If Button = 1 Then
        SelectIndex = vsListView1.ItemHitTest(x, y)
    ElseIf Button = 2 Then
        SelectIndex = vsListView1.ItemHitTest(x, y)
        If SelectIndex >= 0 Then
            PopupMenu mnuFile, 2
        End If
    End If
   
End Sub
#4
cwa99582020-11-30 09:36
我说的是程序,不是代码。
#5
mmy198112172020-11-30 18:53
回复 4楼 cwa9958
这是我写的程序
https://pan.baidu.com/s/1tPSallACYfxPqziqLdMZ2A 提取码3qaz
#6
dasdaa2020-12-04 13:01
谢谢分享!!
#7
yuma2021-01-09 20:00
VB6可以设置焦点
List1.SetFocus


例如:
Private Sub Form_Activate()
Text1.SetFocus
End Sub
1