How to pass an EventArgs to OnClick upon clicking a control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

When you click a control, OnClick is called which in turn calls the Click
event. OnClick takes as an argument an object of type EventArgs which it
then passes to Click. However, the default behavior is that the EventArgs
that is sent is an empty one. I want to pass in some values in my EventArgs
when the user clicks my control. How do I do this?

Thanks,

Nima
 
Override OnClick
Nima said:
Hi all,

When you click a control, OnClick is called which in turn calls the Click
event. OnClick takes as an argument an object of type EventArgs which it
then passes to Click. However, the default behavior is that the EventArgs
that is sent is an empty one. I want to pass in some values in my
EventArgs
when the user clicks my control. How do I do this?

Override OnClick:

protected virtual OnClick(EventArgs e) { // e will be EventArgs.Emppty
MyEventArgs eventArgs = new MyEventArgs();
base.OnClick(eventArgs);
}
 
Back
Top