预览模式: 普通 | 列表

VB右键选定listview控件中的某一行

ASP/Visual Basic代码
  1. Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)  
  2. If Button = 2 then  
  3. ListView1.SelectedItem = ListView1.HitTest(x,y)  
  4. End If  
  5. End Sub  

右键点击空白不弹出菜单

ASP/Visual Basic代码
  1. If ( Button = 2) and (not ListView1.SelectedItem is nothing) then  
  2. popupmenu menu...  
  3. end if   

Tags: vb

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2541

VB中HitTest的用法

 ListView控件和TreeView控件都提供了HitTest方法。这个方法返回对位于x和 y 坐标的 ListItem 对象或 Node 对象的引用。通常与拖放操作或鼠标移动操作一 起使用,来确定鼠标下的目标项在当前位置是否可用。
其语法为:
object.HitTest (x As Single, y As Single)

ASP/Visual Basic代码
  1. Private Sub Form_Load()  
  2. ListView1.ListItems.Add , , "VB程序测试"  
  3. ListView1.ListItems.Add , , "HitTest测试"  
  4. ListView1.ListItems.Add , , "Http://www.jlist.cn"  
  5. End Sub  
  6. Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)  
  7. Dim iItem As ListItem  
  8. Set iItem = ListView1.HitTest(x, y)  
  9. If iItem Is Nothing Then Exit Sub  
  10. ListView1.ToolTipText = iItem.Text  
  11. End Sub  

查看更多...

Tags: vb

分类:技术文章 | 固定链接 | 评论: 1 | 引用: 0 | 查看次数: 3377

 广告位

↑返回顶部↑