Results 1 to 14 of 14

Thread: [RESOLVED] Popup Menu

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Resolved [RESOLVED] Popup Menu

    Apparently the Me.Popup doesn't work in VB.NET, and the Help Contents aren't helping. How do i show a Contextmenu that I've already created at design time? Thanks!
    Last edited by acrym; Mar 21st, 2011 at 07:46 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Popup Menu

    If the Help contents aren't helping then it's most likely because you're looking in the wrong place. First up, is it a Windows Forms ContextMenu, a Windows Forms ContextMenuStrip or a WPF ContextMenu? Secondly, under what circumstances do you want the menu displayed because, if it's on a right-click, you probably don't need any code at all?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    I think it's a Windows Form Contextmenu

    And i want a menu displayed in a picturebox/imagebox mousedown event (right click)

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Popup Menu

    set your picturebox's contextmenustrip property then run your project + right click the picturebox

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    I could only find ContextMenu, and it won't let me edit it in the properties menu

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Popup Menu

    i just checked vb2005 + 8 + 10 windows forms
    they all have a contextmenustrip property for the picturebox

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    Maybe its because i migrated this from VB 6.0... i will keep trying though. thanks

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Popup Menu

    What version of VB.NET are you using? If it's 2002 or 2003 then you will have a ContextMenu item in the Toolbox and each control will have a ContextMenu property. If it's 2005, 2008 or 2010 then you will have a ContextMenuStrip item in the Toolbox and each control will have a ContextMenuStrip property. They are both very similar and do the same job. Either way, add an item to the form from the Toolbox, add items to the menu in the designer and assign the menu to the appropriate property of the desired control. When you right-click the control, the menu will be displayed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    It's either 2002 or 2003. But, do i have to create all my items from scratch? I have these menus that were made from the Menu Editor in VB 6.0 and they're just sitting on top of my form. I can reference them and everything but the one thing I can't do is show them. (I can show contextmenus created from scratch though).

    Plus I can't see how to assign an event when you click on an item in the "new" contextmenu anyways Sorry newbie question!

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Popup Menu

    I'm afraid I have no knowledge of how menus upgraded from VB6 behave. I would suggest recreating them regardless.

    A MenuItem object has a Click event, just like a Button. Just like a Button, you double-click it in the designer to generate a Click event handler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    Ok I can recreate them. Thanks

    But still having trouble with these "new" contextemenus... I see the click event like you said but where's the event for clicking a specific item in that contextemenu? Plus I can only seem to assign items to it at runtime...

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Popup Menu

    there's an overload of the menuitem.add method where you can specify a click event handler.

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Popup Menu

    You're trying to make this difficult when it's not. As I have already said, to create a handler for the Click event of a MenuItem, you double-click that MenuItem in the designer, just as you do with a Button.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Aug 2010
    Posts
    164

    Re: Popup Menu

    Ok thank you paul and Jmcil. It turned out the old menus I had were messing up adding contextmenus to the top of the form. Which i was then able to add events for like you said x) . Thanks!

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