Code
private void t_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) || e.KeyChar == (char)8)
{
return;
}
else
{
var txt = (TextBox)sender;
var str = txt.Text.Insert(txt.SelectionStart,e.KeyChar.ToString() + "0");
decimal d;
if (!decimal.TryParse(str, out d))
{
e.Handled = true;
}
}
}
private void t_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) || e.KeyChar == (char)8)
{
return;
}
else
{
var txt = (TextBox)sender;
var str = txt.Text.Insert(txt.SelectionStart,e.KeyChar.ToString() + "0");
decimal d;
if (!decimal.TryParse(str, out d))
{
e.Handled = true;
}
}
}