Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8851639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:12:15+00:00 2026-06-14T13:12:15+00:00

Event Handler public void DeliverEvent(object sender, EventArgs e) { } #1: This Works public

  • 0

Event Handler

public void DeliverEvent(object sender, EventArgs e)
{

}

#1: This Works

public void StartListening(Button source)
{
    source.Click += DeliverEvent;
}

#2: And so does this..

public void StartListening(EventHandler eventHandler)
{
    eventHandler += DeliverEvent;
}

But in #2, you cannot call the method because if you try something like this:

StartListening(button.Click);

You get this error:

The event 'System.Windows.Forms.Control.Click' can only appear on the left hand side of += or -=

Is there any way around that error? I want to be able to pass the event and not the object housing the event to the StartListening method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:12:16+00:00Added an answer on June 14, 2026 at 1:12 pm

    You are mixing events with delegates. You should probably read this article by Jon Skeet which will explain the differences between the two.

    The reason the second option doesn’t work is because the method expects a parameter that is a delegate that conforms to the EventHandler signature.Button.Click refers to an event rather than a delegate. Events just encapsulate delegates.

    I’m not sure what you are trying can be done. Conceptually what you want to do doesn’t actually make sense; it is the logic of the handler you want to pass around not the event itself.

    Take a look at this post which looks at some ways of simulating the effect you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code for an event handler: rbM.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton
I have this code for example for an event handler public void ONDataArrived (
When I write an event handler for csharp, it looks like this: public void
Encountered a strange problem with this event, event wrapper and handler: public delegate void
I have this code : class Event{}; class CustomEvent:public Event{}; class Handler { public:
I have a textbox tbx. For it I had an event handler: public void
Consider the following class: public class Event<T> { public delegate void Handler<t>(t msg); private
I have declared a generic event handler public delegate void EventHandler(); to which I
I have the following code public abstract class Event { public void fire(Object... args)
I have done like this for creating click event handler for one part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.