Under .NET framework, by convention, all events have this format.
The reasoning for the first argument is that a single event handler can be attached to the same event like so.
btnTestA.Click += new EventHandler(btnTest_Click);
btnTestB.Click += new EventHandler(btnTest_Click);
When btnTestA and btnTestB is clicked, the btnTest_Click event handler will be fired. The "object sender" portion will be a reference to whatever one of the buttons was clicked ...
private void btnTest_Click(object sender, EventArgs e)
{
Button test = sender as Button;
// etc ...
}
The EventArgs portion is a way to pass extra information to the event handler. In the case above, EventArgs is a base class and no real extra information is passed. However, alot of events use a derivative of EventArgs, which contain extra information.
:
: Hello,
:
: what is the meaning of ( object sender, System.EventArgs e )
: when they are together as parameters of function of event of
: a button, like :
: public void rotation_Click(object sender, System.EventArgs e);
:
:
: Bye,
:
: richard
:
: