Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>



Using custom functions directly
The OnIsCustomFunction and OnCalcCustomFunction events can be used to implement custom functions for TAdvSpreadGrid. Via the event OnIsCustomFunction event, the grid is informed what names should be treated as custom functions and the OnCalcCustomFunction performs the actual calculation of the function. With the example code presented, the MYTEST function is added that returns as a result parameter * 2:
procedure TForm2.AdvSpreadGrid1CalcCustomFunction(sender: TObject; var func: string; var param: Double); begin if func='MYTEST' then param := param *2; end; procedure TForm2.AdvSpreadGrid1IsCustomFunction(sender: TObject; var func: string; var match: Boolean); begin match := func='MYTEST'; end; procedure TForm2.FormCreate(Sender: TObject); begin advspreadgrid1.Cells[1,1] := '1'; advspreadgrid1.Cells[1,2] := '=MYTEST(A1)'; advspreadgrid1.Recalc; end;