As I can perform a multiplication in real time of two textbox and show the result in a third textbox, I'm doing it this way but the result does not come out.
private void txtPrecioUnitario_KeyPress(object sender, KeyPressEventArgs e)
{
if (txtPrecioUnitario.Text.Contains('.'))
{
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
if (e.KeyChar == '\b')
{
e.Handled = false;
}
}
else
{
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
if (e.KeyChar =='.' || e.KeyChar =='\b')
{
e.Handled = false;
}
}
int total;
total = int.Parse(txtPrecioUnitario.Text) * int.Parse(txtCantidad.Text);
txtTotal.Text = Convert.ToString(total.ToString());
}
private void txtCantidad_KeyPress(object sender, KeyPressEventArgs e)
{
if (txtCantidad.Text.Contains('.'))
{
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
if (e.KeyChar == '\b')
{
e.Handled = false;
}
}
else
{
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
if (e.KeyChar == '.' || e.KeyChar == '\b')
{
e.Handled = false;
}
}
}