Today we will discuss about Display Form Icon in the Menu Strip of MDI Form
public static void BOValidation(KeyPressEventValidation mode, KeyPressEventArgs e, object sender)
{
switch (mode)
{
case KeyPressEventValidation.Alphabets:
if (!char.IsLetter(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32)
e.Handled = true;
break;
case KeyPressEventValidation.AlphabetValidation:
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar) && e.KeyChar != 32)
e.Handled = true;
break;
case KeyPressEventValidation.AlphaNumeric:
if (!char.IsLetter(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32 && e.KeyChar != 45)
e.Handled = true;
break;
case KeyPressEventValidation.CompanyName:
if (!char.IsLetter(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32 && e.KeyChar != 38 && e.KeyChar != 45 && e.KeyChar != 40 && e.KeyChar != 46 && e.KeyChar != 40)
e.Handled = true;
break;
case KeyPressEventValidation.DecimalValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') e.Handled = true;
// To allow only one decimal point if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1 )
e.Handled = true;
break; case KeyPressEventValidation.FilePathvalidation:
if ((e.KeyChar >= 48 && e.KeyChar <= 57) && (e.KeyChar >= 65 && e.KeyChar <= 122) && e.KeyChar == 92)
e.Handled = true;
break;
case KeyPressEventValidation.IntegerValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
break;
case KeyPressEventValidation.PhoneValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 32 && e.KeyChar != 40 && e.KeyChar != 41 && e.KeyChar != 43 && e.KeyChar != 45)
e.Handled = true;
break;
case KeyPressEventValidation.ValidateSpecialCharacters:
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
e.Handled = true;
break;
case KeyPressEventValidation.PercentageValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
// only allow one decimal point
if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
{
e.Handled = true;
}
if (!char.IsControl(e.KeyChar))
{
TextBox textBox = (TextBox)sender;
if (textBox.Text.IndexOf('.') > -1 && textBox.Text.Substring(textBox.Text.IndexOf('.')).Length >= 3)
{
e.Handled = true;
}
}
break;
}
}
{
switch (mode)
{
case KeyPressEventValidation.Alphabets:
if (!char.IsLetter(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32)
e.Handled = true;
break;
case KeyPressEventValidation.AlphabetValidation:
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar) && e.KeyChar != 32)
e.Handled = true;
break;
case KeyPressEventValidation.AlphaNumeric:
if (!char.IsLetter(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32 && e.KeyChar != 45)
e.Handled = true;
break;
case KeyPressEventValidation.CompanyName:
if (!char.IsLetter(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 8 && e.KeyChar != 32 && e.KeyChar != 38 && e.KeyChar != 45 && e.KeyChar != 40 && e.KeyChar != 46 && e.KeyChar != 40)
e.Handled = true;
break;
case KeyPressEventValidation.DecimalValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') e.Handled = true;
// To allow only one decimal point if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1 )
e.Handled = true;
break; case KeyPressEventValidation.FilePathvalidation:
if ((e.KeyChar >= 48 && e.KeyChar <= 57) && (e.KeyChar >= 65 && e.KeyChar <= 122) && e.KeyChar == 92)
e.Handled = true;
break;
case KeyPressEventValidation.IntegerValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
break;
case KeyPressEventValidation.PhoneValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != 32 && e.KeyChar != 40 && e.KeyChar != 41 && e.KeyChar != 43 && e.KeyChar != 45)
e.Handled = true;
break;
case KeyPressEventValidation.ValidateSpecialCharacters:
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
e.Handled = true;
break;
case KeyPressEventValidation.PercentageValidation:
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
{
e.Handled = true;
}
// only allow one decimal point
if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
{
e.Handled = true;
}
if (!char.IsControl(e.KeyChar))
{
TextBox textBox = (TextBox)sender;
if (textBox.Text.IndexOf('.') > -1 && textBox.Text.Substring(textBox.Text.IndexOf('.')).Length >= 3)
{
e.Handled = true;
}
}
break;
}
}