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
  1. Home
  2. General Programming
  3. C#
  4. How to trigger menu click event from a user control?

How to trigger menu click event from a user control?

Scheduled Pinned Locked Moved C#
questionc++databasetutorial
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.
  • S Offline
    S Offline
    Sarvan AL
    wrote on last edited by
    #1

    I have a user control in the form. I have written some code in menu click event in the form class. When I click a button in the user control, the same thing should happen as I clicked a menu item. How can I make this event to happen from the user control class, like "SendMessage" is used in VC++...

    C M 2 Replies Last reply
    0
    • S Sarvan AL

      I have a user control in the form. I have written some code in menu click event in the form class. When I click a button in the user control, the same thing should happen as I clicked a menu item. How can I make this event to happen from the user control class, like "SendMessage" is used in VC++...

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use a delegate to send a message back to the parent form, then hook up the menu event to call the same method.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • S Sarvan AL

        I have a user control in the form. I have written some code in menu click event in the form class. When I click a button in the user control, the same thing should happen as I clicked a menu item. How can I make this event to happen from the user control class, like "SendMessage" is used in VC++...

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        Hello, You should work with delegates here. Your form could handle a userevent from your UserControl. All the best, Martin

        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