delphi - 如何使 TProgressColumn 与 LiveBindings 和数据集一起使用时工作

标签 delphi firemonkey livebindings tgrid delphi-xe7

我的目标是拥有一个包含多个列的 TGrid,通过 LiveBindings 连接到 TClientDataSet。其中一列的类型为 TProgressColumn。

网格显示数据,但进度栏列不显示任何内容(即 0% 进度)。

TProgressColumn 连接到 ftInteger 类型的字段。该字段中的值介于 0 到 100 之间。

我尝试过 ftSingle,但没有成功。 我通过 ColumnStyle 属性将列的类型设置为 TProgressColumn,该属性位于 TLinkGridToDataSourceBindSourceDB/Columns 下。

奇怪的是,当我使用 TPrototypeBindSource 生成值时 - TProgressColumn 可以工作,但仅适用于 ftUInteger 值。 ftInteger 生成器失败。

这是一个小演示(Delphi XE7):

TProgressColumn issues

当我在 TProgressCell.DrawCell() 中放置断点并跳过 Value.IsOrdinal 和 Value.IsType 的两个条件时,将跳过 Value.IsOrdinal 和 Value.IsType 的两个条件,并且 ClampValue 收到值为 0 的“Min”。 传递给函数的值似乎有问题。

使用 TProgressColumn 时有什么特别的吗?我需要在 TLinkGridToDataSourceColumn 中使用 CustomFormat、CustomParse 吗?

这是一个错误还是我错过了什么?

更新: 感谢“nompa”,谜团被解开了!

事实上“asInteger”是 TField 类众所周知的属性,即:

someDataSet.fieldByName('myFieldName').asInteger

TProgressColumn - SOLVED!

在 CustomFormat 属性中,您可以访问许多内容,包括 self.asInteger 属性。 更多信息请参见:

  1. Using Custom Format and Parse Expressions in LiveBindings
  2. Using binding expressions in the CustomFormat property of a TLinkPropertyToField component
  3. Formatting your Fields
  4. How to treat an Integer field as a Boolean?

最佳答案

该值默认为字符串,无论是整数字段。在属性 CustomFormat 中写入 AsInteger。 该值将被视为整数,并且现在进度可见。

关于delphi - 如何使 TProgressColumn 与 LiveBindings 和数据集一起使用时工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25732866/

相关文章:

delphi - 如何开始使用 Delphi 创建我自己的类?

delphi - 在运行时创建 TQReport 元素

android - 如何检测Android中程序的终止?

Delphi Livebound 对象和组合框或单选按钮

delphi - 使用 Firemonkey 和 Delphi XE2 进行数据库查找字段

delphi - 如何获取 IDE 中所有已安装的组件? (德尔福)

firemonkey - 在主 UI 线程之外显示消息对话框表单

delphi - Firemonkey T编辑高度

delphi - 如何使用实时绑定(bind)将 blob 字段绑定(bind)到 TImage 控件?

delphi - Delphi 中的 Jabber 有完整的库吗?