I'm trying to highlight text in every controls as it enters. It works fine when I'm using MouseClick event. But when using Enter event, it doesn't work. I need to use Enter event instead of MouseClick event because I want to highlight the text no matter how each control gets focus. I can debug the Enter event, and can see that it's processing through. But for some reason SelectAll() is not being processed at all. Why the different behavior?
// This works
private void ClientEdit_MouseClick(object sender, MouseEventArgs e)
{
Control c = sender as Control;
if (c is TextBox) (sender as TextBox).SelectAll();
else if (c is MaskedTextBox) (sender as MaskedTextBox).SelectAll();
}
// This does not work
private void ClientEdit_Enter(object sender, EventArgs e)
{
Control c = sender as Control;
if (c is TextBox) (sender as TextBox).SelectAll();
else if (c is MaskedTextBox) (sender as MaskedTextBox).SelectAll();
}