Get control call method name
2 answers
This is a parameter sender
.
If you know the time, you can do it accordingly:
NumericUpDownControl control = (NumericUpDownControl) sender;
If it can be any of several types, you can use as
both a null test, or is
followed by a cast.
Of course, you only need to specify the type that contains the members you want - so you can just cast to Control
eg.
EDIT: Suppose you just need a name and you know that the sender will always be in control of some kind. You can use:
private void SetColors(object sender, EventArgs e)
{
Control control = (Control) sender;
String name = control.Name;
// Use the name here
}
+10
a source to share