windows form when you you want to user can not press invalid data in textbox or comboBox then pass the ASC ii value on and between...............
private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
try
{
if ((e.KeyChar >= 65 && e.KeyChar <= 90) || (e.KeyChar >= 97 && e.KeyChar <= 122) || (e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == 32 || e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
MessageBox.Show("Invalied");
}
}
catch (Exception)
{
// throw;
}
}
No comments:
Post a Comment