AL_MemTable

Top  Previous  Next

(*

AL_MemoryTable component

 

Modified TRxMemoryData component

New published property:

     DataSet: TDataSet  : source dataset for structure

 

*)

 

unit AL_MemTable;

 

interface

 

uses Windows, SysUtils, Classes, Controls, DB, RxMemDS, DBUtils;

 

Type

 

TALMemoryTable = class(TRxMemoryData)

private

   FDataSet: TDataSet;

   procedure SetDataSet(const Value: TDataSet);

public

   constructor Create(AOwner: TComponent); override;

   destructor Destroy; override;

published

   property DataSet: TDataSet read FDataSet write SetDataSet;

end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

RegisterComponents('AL',[TALMemoryTable]);

end;

 

{ AL_MemoryTable }

 

constructor TALMemoryTable.Create(AOwner: TComponent);

begin

inherited;

FDataSet  := nil;

end;

 

destructor TALMemoryTable.Destroy;

begin

if FDataSet<>nil

    then FDataSet.Free;

inherited;

end;

 

procedure TALMemoryTable.SetDataSet(const Value: TDataSet);

var i: integer;

begin

Try

FDataSet := Value;

Active := False;

DisableControls;

Close;

if FDataSet<>nil then

    CopyStructure(FDataSet)

else begin

   FieldDefs.Clear;

   for I := FieldDefs.Count - 1 downto 0 do

       FieldDefs.Items[I].Free;

end;

finally

Open;

Refresh;

EnableControls;

end;

end;

 

end.