Colouring TppVariable in Group Header according to value
I have a report with grouping, Group Headers contain TppVariables to show results of calculations based on detail lines. I need to colour the text according to the value ( ie over or under 100, or zero)
When I use the following code in the GetText event, all my text appears grey, whatever the value, any idea why? I have a feeling it has to do with the timing of the gettext relative to the calculation, but not sure how to debug this.
I am using Delphi Pro 5, Report Builder Pro 5.56
procedure TfrmIllumineMain.VariableGetTextColour(Sender: TObject;
var Text: String);
var
dTextValue : double;
begin
try
dTextValue :=StrToFloat(Text); //allow for invalid value (inc null)
except
dTextValue := 0; //default to zero if invalid conversion
end;
with Sender as TppVariable do
begin
if dTextValue = 0 then Font.Color := clGray else //grey if zero
if dTextValue < 100 then Font.Color := clBlue else //blue if <100
Font.Color := clRed //red if >100
end;
end;
Best Regards
Will Dutson
Blue Sheep Ltd
When I use the following code in the GetText event, all my text appears grey, whatever the value, any idea why? I have a feeling it has to do with the timing of the gettext relative to the calculation, but not sure how to debug this.
I am using Delphi Pro 5, Report Builder Pro 5.56
procedure TfrmIllumineMain.VariableGetTextColour(Sender: TObject;
var Text: String);
var
dTextValue : double;
begin
try
dTextValue :=StrToFloat(Text); //allow for invalid value (inc null)
except
dTextValue := 0; //default to zero if invalid conversion
end;
with Sender as TppVariable do
begin
if dTextValue = 0 then Font.Color := clGray else //grey if zero
if dTextValue < 100 then Font.Color := clBlue else //blue if <100
Font.Color := clRed //red if >100
end;
end;
Best Regards
Will Dutson
Blue Sheep Ltd
This discussion has been closed.
Comments
Instead of using the GetText event, try changing the Font.Color of the
variables inside the OnCalc events. Below is an example of how I did this.
http://www.digital-metaphors.com/tips/ColoredVariable.zip
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I implemented tha code you suggested, but it appears to 'randomly' apply the colour, as if another event is changing the value after the oncalc event has occurred. I can't see how this is possible. Is it possible that the Variable Calc Timing is affecting this. I am using Calc on Pipeline Traversal, Reset on GroupStart, which give me the correct figures.
Best Regards
Will
Hi Will,
Instead of using the GetText event, try changing the Font.Color of the
variables inside the OnCalc events. Below is an example of how I did this.
http://www.digital-metaphors.com/tips/ColoredVariable.zip
--
Is the code I sent behaving in this manner as well? If possible, please
send an example that demonstrates the issue in .zip format to
support@digital-metaphors.com so I can try to recreate it on my machine.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com