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

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

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

TProgressColumn连接到ftInteger类型的字段.此字段中的值介于0和100之间.

我试过ftSingle,但没有运气.
我通过ColumnStyle属性将列的类型设置为TProgressColumn,可在TLinkGridToDataSourceBindSourceDB / Columns下使用.

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

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

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

使用TProgressColumn时有什么特别之处吗?我是否需要在TLinkGridToDataSourceColumn中使用CustomFormat,CustomParse?

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

更新:
感谢“nompa”,这个谜团已经解决了!

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

someDataSet.fieldByName('myFieldName').asInteger

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

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

最佳答案 默认情况下,该值为字符串,而不是整数字段.在属性CustomFormat中写入AsInteger.

该值将以整数形式显示,现在可以看到进度.

点赞