delphifiremonkeylivebindingstgriddelphi-xe7

How to make TProgressColumn work when used with LiveBindings and datasets


My goal is to have a TGrid with several columns, connected to a TClientDataSet via LiveBindings. One of the columns is of type TProgressColumn.

The grid displays the data, but the progress bar column shows nothing (i.e. 0% progress).

The TProgressColumn is connected to a field of type ftInteger. The values in this field are between 0 and 100.

I've tried with ftSingle, but with no luck. I set the type of the column to be TProgressColumn via ColumnStyle property, available under TLinkGridToDataSourceBindSourceDB/Columns.

The strange thing is that when I use TPrototypeBindSource to generate values - the TProgressColumn works, but only for ftUInteger values. It fails for ftInteger generators.

Here is a little demo (Delphi XE7):

TProgressColumn issues

When I put a breakpoint in TProgressCell.DrawCell() and step over the two conditions for Value.IsOrdinal and Value.IsType are skipped and ClampValue receives a value "Min" which is 0. There seems to be something wrong with the value, passed to the function.

Is there something special when working with TProgressColumn? Do I need to use CustomFormat, CustomParse in TLinkGridToDataSourceColumn?

Is that a bug or I miss something?

UPDATE: Thanks to "nompa" the mystery was solved!

In fact "asInteger" is the well known property of the TField class i.e.:

someDataSet.fieldByName('myFieldName').asInteger

TProgressColumn - SOLVED!

In CustomFormat property you can get access to many things, including self.asInteger properties. More information here:

  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?

Solution

  • The value is string by default, not matter is a integer field. In property CustomFormat write AsInteger. The value will be take as integer and the progress now is visible.