Events?

  • Thread starter Thread starter Mr. Arnold
  • Start date Start date
M

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?
 
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 said:
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.
 
Back
Top