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

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
akiraiu
Posts: 22
Joined: Tue 16 Nov 2004 02:31

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

Post by akiraiu » Tue 29 Mar 2005 07:33

as my topic.
:(

Paul
Posts: 725
Joined: Thu 28 Oct 2004 14:06

Post by Paul » Thu 31 Mar 2005 11:26

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;

akiraiu
Posts: 22
Joined: Tue 16 Nov 2004 02:31

Post by akiraiu » Tue 05 Apr 2005 13:39

Thx thx~~~~ :lol: :lol:

Post Reply