你想实现什么,说清楚了大家才好帮你
我倒有个变通的方法,可以考虑一下,
TFieldDataType = (fdtString, fdtDouble, fdtDateTime……);
TDataType = record;
FiledName: string;
Fieldtype : TFieldDataType;
end;
然后用一个列表来保存,
var
FieldList: TList;
DataType: TDAtaType;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFieldDataType = (fdtString, fdtDouble, fdtDateTime, fdtBoolean);
PDataType = ^TDataType;
TDataType = record
FiledName: string;
Fieldtype : TFieldDataType;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FieldList: TList;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
DataType: PDAtaType;
begin
FieldList := TList.Create;
GetMem(DataType,sizeof(TDataType));
DataType^.FiledName := 'Name';
DataType^.Fieldtype := fdtString;
FieldList.Add(DataType);
GetMem(DataType,sizeof(TDataType));
DataType^.FiledName := 'Sex';
DataType^.Fieldtype := fdtBoolean;
FieldList.Add(DataType);
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
i : Integer;
DataType: PDAtaType;
begin
for i := FieldList.Count - 1 downto 0 do begin
DataType := PDataType(FieldList.Items);
FreeMem(DataType)
//, sizeof(Tdatatype));
end;
FieldList.Clear;
end;
end.
FieldList := TList.Create;
GetMem(DataType: