PRODUCTS

FEATURED PRODUCT

Time & money saving bundle of over 500 components for Windows & IntraWeb application development!

License only 395 EUR See More

SEARCH

LOGIN

Customer login to access products, support information & special benefits.

NEWS ALERTS

Add your e-mail address here to receive the monthly TMS Software alerts.

 

LINKS

EXAMPLE 49

TAdvStringGrid

example 49 : auto calculating floating footers

TAdvStringGrid

It is now very convenient to show automatically calculated values in the fixed floating footer of TAdvStringGrid. Automatic calculations of column sum, column minimum, column maximum, column average and column rowcount can be easily added. Only 2 steps are required to enable this :

grid.FloatingFooter.Visible := True; // show the floating footer grid.FloatingFooter.ColumnCalc[colindex] := CalcType; // set the calculation type for the column colindex in the floating footer.

The calculation type CalcType can be:

acCount: show rowcount
acSum: show column sum
acAvg: show column average
acMin: show column minimum
acMax: show column maximum


As such, the sample app's setup was done with:

procedure TForm1.FormCreate(Sender: TObject);
begin
 AdvStringGrid1.FloatingFooter.ColumnCalc[0] := acCount;
 AdvStringGrid1.FloatingFooter.ColumnCalc[1] := acSum;
 AdvStringGrid1.FloatingFooter.ColumnCalc[2] := acAvg;
 AdvStringGrid1.FloatingFooter.ColumnCalc[3] := acMin;
 AdvStringGrid1.FloatingFooter.ColumnCalc[4] := acMax;
 AdvStringGrid1.RandomFill(False,100);
 AdvstringGrid1.AutoNumberCol(0);
end;

Whenever a cell changes through editing or through loading, the automatically recalculated value shows in the floating footer.

Delphi project & source files for downloading included in the main demos distribution for Delphi.

The project and source files have been written with Delphi 6,7. To use these files in other versions of Delphi, ignore any remarks when opening the form files and save the files. After this, compilation can be done. The error messages are due to properties included in the Delphi 6 form file, but not available in lower versions of Delphi.  

Copyright © 1995 - 2008 TMS Software