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. Call event in another event

Call event in another event

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 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
    Sajjad Leo
    wrote on last edited by
    #1

    Hi, How can I call one event in another event, like I want to call form click event into form load. what should i do for this issue. Please do replay

    D 1 Reply Last reply
    0
    • S Sajjad Leo

      Hi, How can I call one event in another event, like I want to call form click event into form load. what should i do for this issue. Please do replay

      D Offline
      D Offline
      Deresen
      wrote on last edited by
      #2

      You can replay a cd, not a post :). But to call events like you would like, you have to call it just like a function:

      public void Button1_Clicked(object sender, EventArgs e)
      {
      //do some stuff

      //do some stuff the same as button2
      Button2_Clicked(sender, e);
      }

      public void Button2_Clicked(object sender, EventArgs e)
      {
      //do some stuff
      }

      To be honest: this is not really neat. To make it more beautifull, you should just make a function like this:

      public void Button1_Clicked(object sender, EventArgs e)
      {
      //do some stuff

      //do some stuff the same as button2
      doStuffFromButton2();
      }

      public void Button2_Clicked(object sender, EventArgs e)
      {
      //do some stuff
      doStuffFromButton2();
      }

      public void doStuffFromButton2()
      {
      //do some stuff
      }

      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