Events?

Events?

am 28.11.2007 18:44:01 von MR. Arnold

I am building dynamic textboxes in C#. The TextChanged Event for the
textboxs are tied to one Event Handler.

When the event is fired is there a way of finding out by textbox.Name or
something else as to which textbox is firing the event?

Re: Events?

am 28.11.2007 20:23:09 von Jeff Gaines

On 28/11/2007 in message <#ZqMIZeMIHA.5300@TK2MSFTNGP04.phx.gbl> Mr.
Arnold wrote:

>I am building dynamic textboxes in C#. The TextChanged Event for the
>textboxs are tied to one Event Handler.
>
>When the event is fired is there a way of finding out by textbox.Name or
>something else as to which textbox is firing the event?

You can do this:

private void txtTime_TextChanged(object sender, EventArgs e)
{
TextBox txtTemp = sender as TextBox;
}

Then txtTemp will be the TextBox that fired the event.

--
Jeff Gaines

Re: Events?

am 29.11.2007 00:12:46 von MR. Arnold

"Jeff Gaines" wrote in message
news:xn0fe8p2c7m747j004@msnews.microsoft.com...
> On 28/11/2007 in message <#ZqMIZeMIHA.5300@TK2MSFTNGP04.phx.gbl> Mr.
> Arnold wrote:
>
>>I am building dynamic textboxes in C#. The TextChanged Event for the
>>textboxs are tied to one Event Handler.
>>
>>When the event is fired is there a way of finding out by textbox.Name or
>>something else as to which textbox is firing the event?
>
> You can do this:
>
> private void txtTime_TextChanged(object sender, EventArgs e)
> {
> TextBox txtTemp = sender as TextBox;
> }
>
> Then txtTemp will be the TextBox that fired the event.
>

Thanks

After hitting Google for about 20 minutes or so at work, I came upon this
method.

TextBox tb = (TextBox)sender;

It's just another way of doing it I guess.