怎么样在DBGrid中计算两个字段值的乘积?
procedure Tfrmfy.DBGridEh4KeyPress(Sender: TObject; var Key: Char);var
strziduan1, strziduan2:string;
begin
if key=#13 then
begin
Flatbutton5.Click;
if(DBGridEh4.SelectedField.FieldName='xc_cishu')or(DBGridEh4.SelectedField.FieldName='xc_danjia')then
begin
try
strziduan1:=DBGridEh4.DataSource.DataSet.FieldValues['xc_cishu'];
strziduan2:=DBGridEh4.DataSource.DataSet.FieldValues['xc_danjia'];
DBGridEh4.DataSource.DataSet.FieldValues['xc_heji']:=floattostr((strToint (strziduan1)*strTofloat(strziduan2)));
except
showmessage('请将数据填写完整!');
exit;
end;
end;
end;
end;
本文地址:http://www.45fan.com/a/question/67064.html