The Thing
Dec 20th, 2006, 04:22 PM
Hi folks,
I have several buttons on my form that will be calling the same method, but with different actions being performed inside this method depending on whichever button was clicked.
What I am doing is passing into this method the EventArgs e object of each button and then trying to check this via e.Equals() to determine my course of action within the method, but I've had no luck so far. How should I go about getting this to work? I've tried the following, but it wont compile.
if(e.Equals(button1_Click()))
{
//Won't work. :(
}
if (sender.Equals(button4_Click()))
{
//I've tried passing in the sender object, but this doesn't work either.
}
I searched the forums and did a google before posting - I saw mention of delegates and events with examples - but I'm not really any the wiser for it.
A pointer in the right direction would be appreciated thanks.
I have several buttons on my form that will be calling the same method, but with different actions being performed inside this method depending on whichever button was clicked.
What I am doing is passing into this method the EventArgs e object of each button and then trying to check this via e.Equals() to determine my course of action within the method, but I've had no luck so far. How should I go about getting this to work? I've tried the following, but it wont compile.
if(e.Equals(button1_Click()))
{
//Won't work. :(
}
if (sender.Equals(button4_Click()))
{
//I've tried passing in the sender object, but this doesn't work either.
}
I searched the forums and did a google before posting - I saw mention of delegates and events with examples - but I'm not really any the wiser for it.
A pointer in the right direction would be appreciated thanks.