delphi Record 记录集保存Tlist

delphi Record 记录集保存Tlist

  (2011-03-24 09:55:01)
 
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
  hole = record
   id :string;
   name: string;
 
 end;
 
  Th = ^ hole;
var
  Form1: TForm1;
  F :hole;
implementation
 
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
  ListA: TList;
  h:Th;
  i : integer;
begin
  ListA := TList.Create;
 
  new(h);
  h.name := '张';
  h.id  := '1';
  ListA.Add(Pointer(h));
  h:=nil;
  
  new(h);
  h.name := '李';
  h.id  := '2';
  ListA.Add(Pointer(h));
  for i:= 0 to listA.Count-1 do
   begin
       H:=Th(listA.Items[i]);
       showmessage( h.id);
   end;
  listA.Free;
end;
 
end.

猜你喜欢

转载自www.cnblogs.com/bwdblogs/p/10528021.html
今日推荐