Within a sub can I determine the control that called it.
I can add a parameter to the sub so that I call it:
MySub(This, ...
But I'd rather not.
Is there some way to determine the caller within the sub?
Thanks in advance
> Within a sub can I determine the control that called it.
If it's an event handler, then the first parameter "object sender" is
that control; just cast it to the appropriate type, e.g.
void button1_Click(object sender, EventArgs e)
{
Button b = (Button) sender;
}
Otherwise, no, you can't.
Eq.
Academia - 24 Feb 2008 14:41 GMT
I was hoping StackTrace or Reflections, which I know nothing about, would
work.
Thanks.
>> Within a sub can I determine the control that called it.
>
[quoted text clipped - 9 lines]
>
> Eq.