private void OnChecked(object sender, RoutedEventArgs e)
{
try
{
LAB_TEST t = new LAB_TEST();
CheckBox chk = (CheckBox)e.OriginalSource;
if (e.OriginalSource is CheckBox)
{
int OID = Convert.ToInt32(((CheckBox)chk).Tag);
t = eb.TestGetByOID(OID);
bool has = advisedTests.Any(test => test.OID == OID);
if (!has)
{
if (txtGrossAmount.Text != string.Empty)
{
decimal amount = Convert.ToDecimal(txtGrossAmount.Text);
amount += Convert.ToDecimal(t.PRICE);
txtGrossAmount.Text = amount.ToString();
}
else
{
txtGrossAmount.Text = t.PRICE.ToString();
}
advisedTests.Add(t);
}
}
}
catch (Exception ex)
{
}
}
我遇到了一个问题,我在Datagrid中绑定了复选框,并在我们点击复选框时进行一些简单的数学计算,它应该将总和添加到文本框中,它确实这样做了,但问题是鼠标向上或向下滚动会自动勾选或取消勾选复选框,现在文本框中选择项目的总价格比选择的复选框少或多,有时更多,所以鼠标向上或向下滚动会导致此问题。有什么想法吗?谢谢。