Results 1 to 6 of 6

Thread: Right-Click in ListView

  1. #1

    Thread Starter
    New Member oBiOnE's Avatar
    Join Date
    Mar 2001
    Location
    ENgland
    Posts
    15

    Question

    Hi,
    I have a listView in Report Mode, and I need to run a function when an item is clicked with the right-mouse button.

    I can't seem to find a way, as the mousedown event doesn't return the listitem.

    Thanks,
    Mark

  2. #2
    Lively Member Ceri's Avatar
    Join Date
    Sep 2000
    Posts
    72
    use the ListView.SelectedItem.Index to get the index of the selected item, if there is no item selected it will resturn and error 'Object Variable Not Set' so u must catch this error.

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    does the hittest method not work in report mode?
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4
    Guest
    you can use this:
    Code:
    Private Sub ListView1_MouseDown(Button As Integer, shift As Integer, x As Single, y As Single)
        Dim temp As MSComctlLib.ListItem
        If Button = 2 Then
            Set temp = ListView1.HitTest(x, y)
            If Not temp Is Nothing Then
                temp.Selected = True
                '-----Your function code here
            End If
        End If
    End Sub

  5. #5

    Thread Starter
    New Member oBiOnE's Avatar
    Join Date
    Mar 2001
    Location
    ENgland
    Posts
    15

    Wink Thanks

    Thanks ATommasi

    That did it

  6. #6
    Guest

    Red face

    No problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width