private void FathernameTextBox_KeyPress(object sender, KeyPressEventArgs e) { if ((!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar)) || (FathernameTextBox.TextLength == 0 && char.IsLower(e.KeyChar)) || (FathernameTextBox.TextLength > 0 && char.IsUpper(e.KeyChar))) { e.Handled = true; FathernameErrorProvider.SetError(FathernameTextBox, "введен недопустимый символ"); } else { FathernameErrorProvider.Clear(); if (FathernameTextBox.BackColor == Color.IndianRed) { FathernameTextBox.BackColor = Color.White; } } }
private void FathernameTextBox_Leave(object sender, EventArgs e) { FathernameErrorProvider.Clear(); }