Reputation: 41
I am adding got focus event mytextboxes when I create them
`TextBox Xi = new TextBox();
Xi.Name = "X" + i.ToString();
Xi.Width = 10;
Xi.Height = 10;
Xi.GotFocus += Xi_GotFocus;`
But I can't get focused control's name
void Xi_GotFocus(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
is there any way get the name of these controls ? Thank you
Upvotes: 0
Views: 406
Reputation: 7591
you can use below mentioned code
void Xi_GotFocus(object sender, RoutedEventArgs e)
{
TextBox t = sender as TextBox;
string name = t.Name;
}
Upvotes: 1