Results 1 to 5 of 5

Thread: Right click for ListView

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    92

    Right click for ListView

    Hi !

    I want to know how can i add an option such when a user will use the "right click" with the mouse on some item in the listview control , i will open some menu bar and the user be able to preform some operation on this item .


    ThX .

  2. #2
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    VB Code:
    1. Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     If Button = vbRightButton Then
    3.         'do your thing
    4.     End If
    5. End Sub
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  3. #3
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    do a search for

    listview popupmenu

    1. you basically create a menu
    2. put some code in the mousedown event that checks to see if the right mouse was clicked (button = 2)
    3. use the me.popupmenu method to show a menu that you created somewhere.

    If you can't find it, I'll give you some sample code.

  4. #4
    Lively Member
    Join Date
    Sep 2002
    Posts
    89
    don't forget that you can use the X and Y pos to HitTest and get the selected list item

    - gaffa

  5. #5
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    Make a menu ("like File Edit..etc") but dont make it visible, and then use the code below

    VB Code:
    1. Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     If Button = vbRightButton Then
    3.         popUpMenu mnuFile 'opens File menu when u right click
    4.     End If
    5. End Sub
    asdf

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