I have this textbox where the decimal place should only be two, it works but it disables the back space afterwards
try
{
if (string.IsNullOrWhiteSpace(textBox1.Text))
{
textBox2.Clear();
}
else
{
if (Convert.ToDouble(textBox1.Text) > Convert.ToDouble(grandTotal.Text))
{
double change = Convert.ToDouble(textBox1.Text) - Convert.ToDouble(grandTotal.Text);
textBox2.Text = change.ToString("#,0.00");
}
else if (Convert.ToDouble(textBox1.Text) == Convert.ToDouble(grandTotal.Text))
{
textBox2.Text = "0";
}
else
{
textBox2.Clear();
}
}
}
catch(Exception)
{
}
See Question&Answers more detail:os