I have come across this code but not getting it.
it will help to learn new thing if someone explains this code and its use.
Thanx in advance.
I have come across this code but not getting it.
it will help to learn new thing if someone explains this code and its use.
Thanx in advance.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 9, 2013, 9:39 AM
Once you've added an eventhandler for one button, you'll find that in the Properties Box for other buttons the existing handler can be selected from a drop-down list.
In these cases the 'sender' argument contains a reference to which button was actually clicked.
Exactly the same principle applies to other controls and events.
Trupti RanePosted May 9, 2013, 8:25 AM
Ashish ShuklaPosted May 8, 2013, 4:13 AM
EventArgs contains additonal event information.
Since the sender is of type object if we want to retreive information from it we need
to typecast it.
Following represnets a typical click event handler method signature
private void ButtonClick(object sender, EventArgs e)
Since in the above scenario it is of type button hence it is cast to Button using (Button)Sender
Please let me know if this answers your question.