private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
string pattern = @"^[0-9]|\.$";
Regex reg = new Regex(pattern);
if (!reg.Match(e.KeyChar.ToString()).Success)
e.Handled = true;
}