1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
private void textFaxContact_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
char sCaractere = e.KeyChar;
if (Char.IsControl(sCaractere))
return;
e.Handled = true;
// si le caractère saisi n'est pas un chiffre, on sort
if (!Char.IsDigit(sCaractere))
return;
// si le 1er caractère saisi n'est pas un 0, on sort
if (textFaxContact.Text.Length == 0 && sCaractere.ToString() != "0")
return;
textFaxContact.Text += sCaractere;
textFaxContact.Select(textFaxContact.Text.Length, 0);
} |