Set Color of Shapes based on Final Calculation Value with Look Ahead
Hi!
I have a TppDBCalc, with Look Ahead = True, dcSum of a DB Field, on a Group.
Well, I want to change the color of a Shape inside this Group, based on the
final calculation value.
Have tried :
If (DBCalcFieldSum1.Value >= 1000) Then Shape1.Brush.Color := clGreen;
Have tried on GroupAfterPrint, GroupBeforePrint, OnCalc, OnPrint, OnGetText,
nothing works...
Sure this is easy as it sounds...Have been using RB for 4 years, it's
incredible how I cannot figure it such an easy problem...
Thanks in advance!
I have a TppDBCalc, with Look Ahead = True, dcSum of a DB Field, on a Group.
Well, I want to change the color of a Shape inside this Group, based on the
final calculation value.
Have tried :
If (DBCalcFieldSum1.Value >= 1000) Then Shape1.Brush.Color := clGreen;
Have tried on GroupAfterPrint, GroupBeforePrint, OnCalc, OnPrint, OnGetText,
nothing works...
Sure this is easy as it sounds...Have been using RB for 4 years, it's
incredible how I cannot figure it such an easy problem...
Thanks in advance!
This discussion has been closed.
Comments
Take a look at the following rbWiki article on making calculations with a
look ahead value. The same techniques will apply. Note that you will need
to change the color of the shape before the shape is printed.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/How_To...Use_a_Look_Ahead_Value_in_a_Calculation
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
That worked, thanks a lot!
Murilo C. Monteiro
function TForm1.GetLookAheadTotal(Calculo:TppDBCalc): Variant;
var
lsTotal: String;
begin
lsTotal := Calculo.GetLookAheadValue(Calculo.GetLookAheadKey);
lsTotal := StringReplace(lsTotal, '.', '', [rfReplaceAll]);
Result := StrToFloat(lsTotal);
end;
If (GetLookAheadTotal(DBCalc1) >= 1000) Then shpGrupoKm.Brush.Color :=
clGreen Else shpGrupoKm.Brush.Color := clYellow;
Worked like a charm.