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. accessing events

accessing events

Scheduled Pinned Locked Moved C#
tutorialquestion
4 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.
  • I Offline
    I Offline
    i gr8
    wrote on last edited by
    #1

    access the events of class using its object. how to do this?

    OriginalGriffO 1 Reply Last reply
    0
    • I i gr8

      access the events of class using its object. how to do this?

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      MyClass myClassInstance = new MyClass();
      myClassInstance.EventName += new EventHandler(MethodToHandleTheEvent);
      ...
      private void MethodToHandleTheEvent(object sender, EventArgs e)
      {
      ... handle the event
      }

      I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      L 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        MyClass myClassInstance = new MyClass();
        myClassInstance.EventName += new EventHandler(MethodToHandleTheEvent);
        ...
        private void MethodToHandleTheEvent(object sender, EventArgs e)
        {
        ... handle the event
        }

        I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        ur codez not compile. plz fix asap. u not gr8! :mad:

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read formatted code with indentation, so please use PRE tags for code snippets.


        I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


        OriginalGriffO 1 Reply Last reply
        0
        • L Luc Pattyn

          ur codez not compile. plz fix asap. u not gr8! :mad:

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read formatted code with indentation, so please use PRE tags for code snippets.


          I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          :laugh: You should upgrade to VS2012 - .NET 5.0 has full support for the ellipsis automatic code generation command "..."

          I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          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