Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Context Menu Event setup

Context Menu Event setup

Scheduled Pinned Locked Moved Visual Basic
csharpregexhelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JaeBeam
    wrote on last edited by
    #1

    I have a context menu running for a vb.net windows service controller I've created. Folks can turn the windows service on and off with the application. I change the caption for the local mene each time the user changes the service status. (Startup service/ shutdown service) This works great until somebody changes the service status independantly of my service controller. Then the captions don't match. I'd like to capture the "right click" event of my context menu, so to speak, to make certain I have my service's status displayed correctly. I don't know how to do this with a dynamically created context menu. I can add events associated with specific menuitem w/i my context menu without issue.

    D L 2 Replies Last reply
    0
    • J JaeBeam

      I have a context menu running for a vb.net windows service controller I've created. Folks can turn the windows service on and off with the application. I change the caption for the local mene each time the user changes the service status. (Startup service/ shutdown service) This works great until somebody changes the service status independantly of my service controller. Then the captions don't match. I'd like to capture the "right click" event of my context menu, so to speak, to make certain I have my service's status displayed correctly. I don't know how to do this with a dynamically created context menu. I can add events associated with specific menuitem w/i my context menu without issue.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It's not very clear where you want this code to run. Are you saying that you have a context menu that pops up on a right-click of a form or some other control and you want to update the status then? Or do you want to update the status when right-clicking an item in the context menu?? It's easy to wire up the events using AddHandler. You just have to write the method up with the correct header, matching what the event you're going to use expects.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      1 Reply Last reply
      0
      • J JaeBeam

        I have a context menu running for a vb.net windows service controller I've created. Folks can turn the windows service on and off with the application. I change the caption for the local mene each time the user changes the service status. (Startup service/ shutdown service) This works great until somebody changes the service status independantly of my service controller. Then the captions don't match. I'd like to capture the "right click" event of my context menu, so to speak, to make certain I have my service's status displayed correctly. I don't know how to do this with a dynamically created context menu. I can add events associated with specific menuitem w/i my context menu without issue.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        JaeBeam wrote:

        This works great until somebody changes the service status independantly of my service controller. Then the captions don't match.

        Would it be an option to get the latest status and setting the caption, just before the menu is about to pop up? In that case, you could wire up the PopUp[^]-event, and set the caption from there.

        I are Troll :suss:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups