http://www.tmssoftware.com/上有详细说明With the floating footer (for which the settings are organised in the property grid.FloatingFooter) an always visible fixed footer can be displayed in the grid. The floating footer can currently be organised in 3 different ways set by the FooterStyle property :fsFixedLastRow fsColumnPreview fsCustomPreview ---------------- In this sample application, the fsFixedLastRow style is choosen and the last row is used to display the column sums. The following method puts the column sums into the last row: procedure TForm1.UpdateSums; var i: Integer; begin for i := 1 to AdvStringGrid1.ColCount - 1 do AdvStringGrid1.Floats[i,AdvStringGrid1.RowCount - 1] := AdvStringGrid1.ColumnSum(i,1,AdvStringGrid1.RowCount - 2); AdvStringGrid1.FloatingFooter.Invalidate; end; -------------------------------------------- To synchronise updating the floating footer whenever a cell value changes through editing, the UpdateSums method is called from the OnCellValidate event which is triggered whenever editing changes a cell. procedure TForm1.AdvStringGrid1CellValidate(Sender: TObject; Col, Row: Integer; var Value: String; var Valid: Boolean); begin UpdateSums; end; -------------------------------------
fsColumnPreview
fsCustomPreview
----------------
In this sample application, the fsFixedLastRow style is choosen and the last row is used to display the column sums. The following method puts the column sums into the last row: procedure TForm1.UpdateSums;
var
i: Integer;
begin
for i := 1 to AdvStringGrid1.ColCount - 1 do
AdvStringGrid1.Floats[i,AdvStringGrid1.RowCount - 1] :=
AdvStringGrid1.ColumnSum(i,1,AdvStringGrid1.RowCount - 2);
AdvStringGrid1.FloatingFooter.Invalidate;
end;
--------------------------------------------
To synchronise updating the floating footer whenever a cell value changes through editing, the UpdateSums method is called from the OnCellValidate event which is triggered whenever editing changes a cell. procedure TForm1.AdvStringGrid1CellValidate(Sender: TObject; Col,
Row: Integer; var Value: String; var Valid: Boolean);
begin
UpdateSums;
end;
-------------------------------------