SelectAll in TextBox - DYNAMICLY

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top