//Auto complete the unit price unit base on box private void txtPBox_KeyUp(object sender, KeyEventArgs e) { int input; if (int.TryParse(txtPBox.Text, out input)) { Category _cate = CategoryBUS.getById((int)cboCate.SelectedValue); int? output = (input + _cate.Unit - 1) / _cate.Unit; txtPUnit.Text = output.ToString(); } }