Soulless wrote:
Hi,
I have a form that I need to place 3 buttons on. I would like the 3
buttons to call the same method, perhaps with different arguments.
Why not simply provide the same event handler for all three buttons?
If they will all call the same method with different arguments, you may
as well just have three separate event handlers.
If say two of the three will be the same, it might be simpler to have
them share an event handler then check the sender, a la:
Button first = new Button("One");
Button second = new Button("Two");
Button third = new Button("Three");
first.Click += new EventHandler(mySpecialButton_Click);
second.Click += new EventHandler(mySpecialButton_Click);
third.Click += new EventHandler(mySpecialButton_Click);
private void mySpecialButton_Click(object sender, EventArgs e)
{
if (sender == first)
SomeOtherMethod("arg1", "arg2", overloaded_int);
else
SomeOtherMethod("arg1", "arg2");
}
Either way, it doesn't look like you need inheritance at all.
Chris.