是否有可能在delphi数据集中创建假数据字段? [英] it's possible to create a fake data field in a delphi dataset?

查看:93
本文介绍了是否有可能在delphi数据集中创建假数据字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据集(不是ClientDataSet)中创建一个假数据字段:

I want to create a 'fake' data field in a DataSet (not ClientDataSet):


  • 该字段不应存储在db

  • 这不是计算字段(应该允许用户输入输入数据)

  • 该字段具有业务逻辑含义,因此在用户更新其值,应该更新其他字段(使用OnFieldChange事件)

我知道我可以拥有一个简单的无垃圾邮件控件,捕获它的OnChange事件并在那里执行计算(或调用DataSet所在的DataModule函数),但我认为如果我可以重新利用带有db-ware控件和数据集事件的数据集自动绑定,那就更干净了。.

I know I can have a simple no-dbaware control, capture it's OnChange event and perform the calculations there (or call a DataModule function, where the DataSet resides) but I think it's more clean if I can reutilize the dataset automatic binding with db-ware controls and dataset events..

通过这种方式,Form(演示文稿)与DataModule(模型)之间的唯一连接就是DataSet(较少耦合)。

Also this way the unique connection between the Form (Presentation) and the DataModule (Model) it's the DataSet (less coupling)..

PD:我正在使用fibplus,我认为解决方案(如果有)将在VCL级别上。

PD: I'm using fibplus, with I think the solution (if any) will be at the VCL level..

谢谢!

推荐答案

您是否尝试过使用InternalCalc字段?数据感知控件将允许您编辑InternalCalc字段的值,并将该值存储在数据集中。

Have you tried using an InternalCalc field? Your data aware controls will let you edit an InternalCalc field's value, and the value is stored in the dataset.

如果您在数据集中创建了InternalCalc字段(TClientDataSet,TQuery等),这几乎正是您要的。

If you create an InternalCalc field in the dataset (TClientDataSet, TQuery, etc.) at design time, it's almost exactly what you're asking for.

这篇关于是否有可能在delphi数据集中创建假数据字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆