SelectAll in TextBox - DYNAMICLY

  • Thread starter Thread starter Freestyler
  • Start date Start date
F

Freestyler

OK this works fine:

private void textBox1_GotFocus(object sender, System.EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
textBox1.SelectAll();
timer1.Enabled = false;
}

.... but I don't want to make one time for each textBox. Especially that I
dynamicly create the textBoxes.
I'd like to do sth like that:

private void timer1_Tick(object sender, System.EventArgs e)
{
((TextBox) sender).SelectAll();
timer1.Enabled = false;
}

..... and put line:

timer1_Tick(sender, System.EventArgs.Empty);

in the GotFocus event handler.

But it doesn't work. WHY ?

Thanks in advance.
Best regards.

Fred.
 
Back
Top