MaskedTextBox.SelectAll on GotFocus doesn't work with mouse
Your SelectAll()
is being overwritten by the default functionality of the masked textbox select. I would use the Enter
event, it allows for tabbed entry or mouse click entry to the masked text box. You will most likely need to use the BeginInvoke
method. Try the code below. It worked for me when I tried...
private void maskedTextBox1_Enter(object sender, EventArgs e)
{
BeginInvoke((Action) delegate { SetMaskedTextBoxSelectAll((MaskedTextBox) sender); });
}
private void SetMaskedTextBoxSelectAll(MaskedTextBox txtbox)
{
txtbox.SelectAll();
}