CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Right-click

  1. #1
    Join Date
    Mar 1999
    Posts
    1

    Right-click



    I would like to be able to right click on something and put choice in there for the user to pick. For instance, for a order entry program have the user right-click on an item have it bring up a box where they can choose to add or delete that item to their order.

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Right-click



    Hi


    You need to create a menu for your application / control / form / whatever.


    In this case, call it mnuPopup, then add some other menu items below it.


    Now on the control you want the menu to popup on, place code similar to the following in the controls_mouseup event :


    eg:


    Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = vbRightButton Then

    PopupMenu mnuPopup

    End If



    End Sub


    Of course - you can make the root menu (mnuPopup) invisible, so that it doesn't appear on the form, but it's sub-items will be visible when you use the above code.


    My VBCodeLibrary program at http://www.codeguru.com/vb/articles/1638.shtml demonstrates the use of popupmenus


    Regards


    Chris Eastwood


    Codeguru - the website for developers

    http://www.codeguru.com/vb




    VBCodeLibrary Program

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

Featured