可以在 delphi 数据集中创建假数据字段吗?

编程入门 行业动态 更新时间:2024-10-19 04:27:49
本文介绍了可以在 delphi 数据集中创建假数据字段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

  • 该字段不应存储在数据库中
  • 这不是一个计算字段(应该允许用户输入输入数据)
  • 该字段具有业务逻辑意义,因此用户更新其值后应更新其他字段(使用 OnFieldChange 事件)

我知道我可以有一个简单的无 dbaware 控件,捕获它的 OnChange 事件并在那里执行计算(或调用 DataModule 函数,DataSet 所在的位置)但我认为如果我可以重新利用数据集自动绑定它会更干净带有 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(Presentation)和 DataModule(Model)之间的独特连接是 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.

如果您在设计时在数据集(TClientDataSet、TQuery 等)中创建一个 InternalCalc 字段,它几乎就是您所要求的.

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 数据集中创建假数据字段吗?

本文发布于:2023-11-13 14:46:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584616.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   字段   delphi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!