Results 1 to 3 of 3

Thread: Right-Click in a ListBox

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    I have a listBox that my users will right-click on an item in the box and I want to present them 2 options...

    Option 1 or Option 2

    Option 1 does some piece of code, option 2 does some other bit of code...

    What is the best way to do that?

    Thanks!
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  2. #2
    Lively Member
    Join Date
    Oct 1999
    Location
    -
    Posts
    101
    use the PopupMenu

    1. create a menu with two submenus
    2. put anything in your two menus (code that is...)
    3. hide the menu
    4. in the ListBox MouseDown event... put this code

    Code:
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        If Button = 2 Then
            PopupMenu mnuMymenu   'mnuMyMenu is the name of your menu
        End If
    
    End Sub
    [Edited by rod on 09-07-2000 at 12:18 AM]
    icq: 16228887

  3. #3

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    That worked perfectly, thank you!!

    One more question...

    Since there may be several items in the list box, how can I tell which one the user right-clicked on?

    lstListBox.ListIndex doesn't do it because a right-click doesn't actually select anything in the box...
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

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