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;
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;
这段代码是关于DBGridEh4的按键事件处理。当按下回车键时,触发Flatbutton5的点击事件。若选中字段为'xc_cishu'或'xc_danjia',则尝试计算'xc_heji'的值,若数据不完整会给出提示。

1658

被折叠的 条评论
为什么被折叠?



