A DataSet hooked to a grid has:
TField.DisplayFormat := '$######.00'
I want to build list of strings that are in a particular column of my grid with:
while NOT DataSet.EOF do
StringList.Add(TField.DisplayText);
I had hoped for speed to do:
DataSet.DisableControls;
but this also disables the application of the DisplayFormat.
Not disabling the controls means this runs quite slowly (in the archaic, deprecated, “You should abandon it now“-Paradox/BDE.)
So, my question:
Is there a formatting function (say, DFFormat) that uses the same notation as TField.DisplayFormat?
Then I could do:
DataSet.DisableControls;
while NOT DataSet.EOF do
StringList.Add(DFFormat(TField.Value));
Or, since there are only have a few data types, so I could do the code below and figure out ways to create a Format string that works:
DataSet.DisableControls;
while NOT DataSet.EOF do
begin
if TField.FieldType = ftString
StringList.Add(AsString)
else if TField.FieldType = ftFloat then
StringList.Add(Format(TField.Value, ...)
else...
The code above wouldn’t be much longer than shown, but I’m hoping there is a formatting function that uses TField’s DisplayFormat. Or am I asking too much?
DisplayFormatonly applies to fourTFielddescendants (TAggregateField,TDateTimeField,TNumericField, andTSQLTimeStampField). It seems to me this would be very easy to implement for three of them: