|
tech
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Events?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? On 28/11/2007 in message <#ZqMIZeMIHA.5***@TK2MSFTNGP04.phx.gbl> Mr.
Arnold wrote: >I am building dynamic textboxes in C#. The TextChanged Event for the You can do this:>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? 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
Show quote
"Jeff Gaines" <whitedragon@newsgroups.nospam> wrote in message Thanksnews:xn0fe8p2c7m747j004@msnews.microsoft.com... > On 28/11/2007 in message <#ZqMIZeMIHA.5***@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. > 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. |
|||||||||||||||||||||||