Page 1 of 1

how to dynamic to create the calc field in the virtua table??

Posted: Tue 29 Mar 2005 07:33
by akiraiu
as my topic.
:(

Posted: Thu 31 Mar 2005 11:26
by Paul
Working with calculated fields in Virtual table is not different from BDE components. For example you can use next code:

Code: Select all

var
  cfld : TFloatField;

implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
//Assume that all fields are added  to Fields list before.
  VirtualTable1.Close;
  cfld := TFloatField.Create(self);
  cfld.FieldName := 'CalcFld';
  cfld.Calculated := true;
  cfld.DataSet := VirtualTable1;
  VirtualTable1.Open;
end;

procedure TForm1.VirtualTable1CalcFields(DataSet: TDataSet);
begin
  cfld.Value := DataSet.FieldByName('EmpNo').AsInteger + DataSet.FieldByName('Sal').AsInteger;
end;

Posted: Tue 05 Apr 2005 13:39
by akiraiu
Thx thx~~~~ :lol: :lol: