解决方案 »
- 如何在combobox中输入内容按回车后让dbgrid的某一列得到焦点(setfocus)?
- delphi怎么读出网络上的记事本文件中的内容
- 三层数据库应用中出现访问拒绝的错误?
- 初学DELPHI~~~一个问题急需高手帮忙解决:
- 我现在得到一个别的程序的实列句柄,现在我想根据该句柄找到该程序 的文件名和路径,(在线等待!)
- 新手上路,一个richedit的问题!如何在richedit的任意位置插入字符;连续undo如何处理?
- 用SQL将表字段改名问题:
- 请问如何限制ie弹出窗口的数目
- 生复指定字符串若干次的函数是哪个,有人记得么
- delphi http接口数据查询问题
- 请各位推荐个DELPHI 免费界面库 谢谢
- 求 非EXE后缀的文件 以EXE执行文件方式运行方法
如果是连着数据集的, 可以通过设定query计算列实现
也可以自己写公式计算金额;
//tv1: TcxGridBandedTableView;
procedure TForm1.tv1EditValueChanged(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem);
var
dPrice, dQuantity, dCoupon : double;
begin
tv1.DataController.Post();
with tv1 do
begin
//金额计算 如果编辑单价, 数量, 优惠, 则计算消费金额
if Controller.FocusedColumnIndex in [clmPrice.Index, clmQuantity.Index, clmCoupon.Index] then
begin
dPrice := DataController.Values[Controller.FocusedRecordIndex, clmPrice.index];
dQuantity := DataController.Values[Controller.FocusedRecordIndex, clmQuantity.index];
dCoupon := DataController.Values[Controller.FocusedRecordIndex, clmCoupon.index]; DataController.Values[Controller.FocusedRecordIndex, clmTotal.index] :=
dPrice * dCoupon / 10 * dQuantity;
end;
end;
end;上边的代码没有做异常处理, lz可以设置列属性为货币型, 并对数值有效性做处理.合计可以通过对金额列页脚求和实现
请问这两段代码是什么意思?谢谢你了。
tv1.DataController.Post();
if Controller.FocusedColumnIndex in [clmPrice.Index, clmQuantity.Index, clmCoupon.Index] then
if Controller.FocusedColumnIndex in [clmPrice.Index, clmQuantity.Index, clmCoupon.Index] then
tv1.DataController.Post() 请问POST后面的()是什么作用?不加()有什么不同?
DataController.Values[Controller.FocusedRecordIndex, clmTotal.index] 这都是基础知识, 你看源码就能解答.tv1.DataController.Post(); //参数为是否强制提交的选项, 因为有默认值, 括号可以省略
tv1.DataController.Post; <==> tv1.DataController.Post();
DataController.Values[Controller.FocusedRecordIndex, clmTotal.index]
获取当前单元格的数值