Textbox which accepts only single dot(.) and numbers

Imteyazkhan374
Posted by Imteyazkhan374 under C# category on | Points: 40 | Views : 839
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar == '.' && textBox1.Text.IndexOf('.') > -1) || char.IsLetter(e.KeyChar) || (e.KeyChar >= (char)33 && e.KeyChar <= (char)45) || char.IsSymbol(e.KeyChar) || (e.KeyChar >= (char)58 && e.KeyChar <= (char)64) || (e.KeyChar >= (char)91 && e.KeyChar <= (char)96) || (e.KeyChar >= (char)123 && e.KeyChar <= (char)126) || e.KeyChar == '/')
{
e.Handled = true;
}

}

Comments or Responses

Login to post response