//Allowed Only Numbers
private void txtRegKey_KeyPress(object sender, KeyPressEventArgs e)
{
if ((!Char.IsDigit(e.KeyChar)) && !(e.KeyChar == (char)8))
{
//MessageBox.Show("only numbers are allowed");
e.Handled = true;
}
}
//Allowed Only Characters
private void txtRegKey_KeyPress(object sender, KeyPressEventArgs e)
{
int ascii = Convert.ToInt16(e.KeyChar);
if ((ascii >= 97 && ascii <= 122) || (ascii == 8) || (ascii >= 65 && ascii <= 90))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
//Allowed Numbers and Charcters
private void txtRegKey_KeyPress(object sender, KeyPressEventArgs e)
{
int ascii = Convert.ToInt16(e.KeyChar);
if ((ascii >= 97 && ascii <= 122) || (ascii == 8) || (ascii >= 65 && ascii <= 90) || (ascii >= 48 && ascii <= 57))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
//Allowed Numbers,Charcters and Spaces
private void txtRegKey_KeyPress(object sender, KeyPressEventArgs e)
{
int ascii = Convert.ToInt16(e.KeyChar);
if ((ascii >= 97 && ascii <= 122) || (ascii == 8) || (ascii >= 65 && ascii <= 90) || (ascii >= 48 && ascii <= 57) || (ascii == 32) )
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
//ASCII Values
No comments:
Post a Comment