还是没听明白,比如:private sub listview1_DBCLICK() (??怎么样知道点了那一行) end sub 括号内的能解释一下吗?试了N次了。
dim xItem as ListItem Set xItem = ListView1.SelectItem if not xItem is nothing then 'xItem.text 'xItem.index end if
在listview,到底怎么样判断点击了那一行,到现在调试都不成功,救救我。
'------------------------------- '晕,这不是说的已经很清楚了么 '难道还要给你注释一下啊 '-------------------------------dim xItem as ListItem Set xItem = ListView1.SelectItem'得到当前选择的行 if not xItem is nothing then'如果选择不为空 'xItem.text 'xItem.index'这是选择的行的索引值,可以使用他来确定你选择的是那一行,或者也可以通过从列表中取值 end if
Private Sub ListView1_DblClick() If Not (ListView1.SelectedItem Is Nothing) Then '打开其他窗体的代码 End If End SubPrivate Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Set ListView1.SelectedItem = ListView1.HitTest(x, y) End Sub
這樣,要在Listview的雙擊事件判斷有沒點中某個Item,
而不是點在空白地方。如果點中某個Item,那就調用新的Form。
(??怎么样知道点了那一行)
end sub
括号内的能解释一下吗?试了N次了。
Set xItem = ListView1.SelectItem
if not xItem is nothing then
'xItem.text
'xItem.index
end if
'晕,这不是说的已经很清楚了么
'难道还要给你注释一下啊
'-------------------------------dim xItem as ListItem
Set xItem = ListView1.SelectItem'得到当前选择的行
if not xItem is nothing then'如果选择不为空
'xItem.text
'xItem.index'这是选择的行的索引值,可以使用他来确定你选择的是那一行,或者也可以通过从列表中取值
end if
Dim lvhti As LVHITTESTINFO
Call GetCursorPos(lvhti.pt)
Call ScreenToClient(listview1.hwnd, lvhti.pt)
Call SendMessage(listview1.hwnd, LVM_SUBITEMHITTEST, 0, lvhti.pt)
i = lvhti.iItem
If i >= 0 Then
i=i+1'這時候的i就是點的行數
end if
以上代碼寫在雙擊事件中,
其中用的到API函數和常量,你自己查資料。
在mousedown事件中取得点击的x,y值,在DBCLICK事件中用HitTest方法判断是否点到item
If Not (ListView1.SelectedItem Is Nothing) Then
'打开其他窗体的代码
End If
End SubPrivate Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Set ListView1.SelectedItem = ListView1.HitTest(x, y)
End Sub