Position the caret in a MaskedTextbox
This should do the trick:
private void maskedTextBox1_Enter(object sender, EventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate()
{
maskedTextBox1.Select(0, 0);
});
}
To improve upon Abbas's working solution, try this:
private void ueTxtAny_Enter(object sender, EventArgs e)
{
//This method will prevent the cursor from being positioned in the middle
//of a textbox when the user clicks in it.
MaskedTextBox textBox = sender as MaskedTextBox;
if (textBox != null)
{
this.BeginInvoke((MethodInvoker)delegate()
{
int pos = textBox.SelectionStart;
if (pos > textBox.Text.Length)
pos = textBox.Text.Length;
textBox.Select(pos, 0);
});
}
}
This event handler can be re-used with multiple boxes, and it doesn't take away the user's ability to position the cursor in the middle of entered data (i.e does not force the cursor into zeroeth position when the box is not empty).
I find this to be more closely mimicking a standard text box. Only glitch remaining (that I can see) is that after 'Enter' event, the user is still able to select the rest of the (empty) mask prompt if xe holds down the mouse and drags to the end.