کد:
int t=0;
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
string s = e.KeyChar.ToString();
if (!(e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == '.' && t<1))
{
e.Handled = true;
}
if (e.KeyChar == '.') t++;
}