How can I make a textbox in which can be only typed a number like 12.00 or 1231231.00 or 123123
I\'ve done this in a very long way and I\'m looking for the best and
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar))
{
e.Handled = !(((TextBox)sender).SelectionStart != 0 && (e.KeyChar.ToString() == Application.CurrentCulture.NumberFormat.NumberDecimalSeparator && ((TextBox)sender).Text.IndexOf(Application.CurrentCulture.NumberFormat.NumberDecimalSeparator) == -1));
}
}
And you should check onLeave for Length == 0 I think...