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. Re: Calling an event to a class in a different namespace

Re: Calling an event to a class in a different namespace

Scheduled Pinned Locked Moved C#
databasetutorialquestion
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.
  • R Offline
    R Offline
    roman_s
    wrote on last edited by
    #1

    Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this

    G N 2 Replies Last reply
    0
    • R roman_s

      Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this

      G Offline
      G Offline
      Ghydo
      wrote on last edited by
      #2

      To fire event you can use the MenuItem.PerformClick method. To call it from the form you should expose a public method in the PanelMasterlist class that fire the delete event, something like this:

      public void DeleteMasterList()
      {
      contextDeleteMasterList.PerformClick();
      }

      1 Reply Last reply
      0
      • R roman_s

        Ok so I have a parent form called frmMain and a child panel called panelMasterlist. In panelMasterList I have created a delete event(right click context button) on the frmMain there is a Delete button as well I need to trigger the same event from the frmMain as in the panelMasterlist. In panelMasterList the clcik event is: public void contextDeleteMasterList_Click(object sender, EventArgs e) so I was thinking in the frmMain I can send a event argument to the namespace.class? Not sure how to do this

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Create a method that handles the action and call it from both the main form menu item and the panel context menu item

        private void Delete()
        {
        // Do something
        }

        protected void OnDeleteMenu(object sender, EventArg e)
        {
        Delete();
        }

        protected void OnDeleteContextMenu(object sender, EventArg e)
        {
        Delete();
        }


        I know the language. I've read a book. - _Madmatt

        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