How to get TProgressColumn to work when used with LiveBindings and datasets

My goal is to have a TGrid with multiple columns connected to 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).

TProgressColumn is connected to a field of type ftInteger. Values ​​in this field range from 0 to 100.

I tried with ftSingle but no luck. I am setting the column type to TProgressColumn through the ColumnStyle property available in TLinkGridToDataSourceBindSourceDB / Columns.

The weird thing is that when I use TPrototypeBindSource to generate values ​​- TProgressColumn works, but only for ftUInteger values. It doesn't work for ftInteger generators.

Here's a small 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, it is skipped and the ClampValue gets the "Min" value, which is 0. There seems to be something wrong with the value. passed to the function.

Is there anything special about TProgressColumn? Do I need to use CustomFormat, CustomParse in TLinkGridToDataSourceColumn?

Is this a bug or am I missing something?

UPDATE: Thanks to "nompa" the mystery has been solved!

In fact "asInteger" is a well-known property of the TField ie class:

someDataSet.fieldByName('myFieldName').asInteger

      

TProgressColumn - SOLVED!

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

+3


source to share


1 answer


The default is a string, not an integer field. In the CustomFormat property write AsInteger. The value will be taken as a whole and progress will now be visible.



+2


source







All Articles