自己用delphi list的體會

delphi 的list使用   版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任
http://writeblog.csdn.net/Default.aspx

  PTdept = ^Tdept;
  Tdept = record
    deptno              : string ;
    deptname         : string ;
    secondname     : string ;
    deptaddr           : string ;
    depttel              : string ;
    deptleader        : string ;
    useflag             : string ;
    stransflag         : string ;
    lieover             : string ;
    stimestamp      : string ;
    smodifyflag     : string ;
    scorpcode        : string ;
    dtmodify          : double ;
    sstopflag          : string ;
    smodifycorpcode    : string ;
  end;

  private
    Pdept : PTdept;
    Ldeptlist : Tlist;
    procedure pclearPdept(dept : Tdept);
    procedure MListtoPrecord;
    { Private declarations }
  public
    { Public declarations }
  end;

procedure TfrmmBase.FormShow(Sender: TObject);
var
  Pdept : PTdept;
begin
  inherited;
  try
    用qyData查出表中的數據;
    with qyData do
    begin
      qyData.First;
      with qyData do
      begin
        while not eof do
        begin
          new(Pdept);
          pclearPdept(Pdept^);
          Pdept.deptno             :=   fieldbyname('deptno').asstring;
          Pdept.deptname        :=   FieldByName('deptname').asstring;
          Pdept.secondname    :=   fieldbyname('secondname').asstring;
          Pdept.deptaddr          :=   fieldbyname('deptaddr').asstring;
          Pdept.depttel             :=   fieldbyname('depttel').asstring;
          Pdept.deptleader       :=   fieldbyname('deptleader').asstring;
          Pdept.useflag            :=   fieldbyname('useflag').asstring;
          Pdept.stransflag        :=   fieldbyname('stransflag').asstring;
          Pdept.lieover             :=   fieldbyname('lieover').asstring;
          Pdept.stimestamp      :=   fieldbyname('stimestamp').asstring;
          Pdept.smodifyflag     :=   fieldbyname('smodifyflag').asstring;
          Pdept.scorpcode       :=   fieldbyname('scorpcode').asstring;
          Pdept.dtmodify         :=   fieldbyname('dtmodify').asfloat;
          Pdept.sstopflag         :=   fieldbyname('sstopflag').asstring;
          Pdept.smodifycorpcode :=   fieldbyname('smodifycorpcode').asstring;
          Ldeptlist.Add(Pdept);
          next;
        end;
      end; 
    end;
    MListtoPrecord;
  finally
    //
  end;
end;

procedure TfrmmBase.MListtoPrecord;
var
  Precord : PTdept;
  icount  : integer;
begin
  asSources.RowCount := Ldeptlist.count+1;
  for icount:= 0 to Ldeptlist.count-1 do
  begin
    Precord := Ldeptlist.items[icount];
    asSources.Cells[0,icount+1]  := Precord.deptno;   //asSources 是一個advstringgrid的name   呵呵
    asSources.Cells[1,icount+1]  := Precord.deptname;
    asSources.Cells[2,icount+1]  := Precord.secondname     ;
    asSources.Cells[3,icount+1]  := Precord.deptaddr           ;
    asSources.Cells[4,icount+1]  := Precord.depttel              ;
    asSources.Cells[5,icount+1]  := Precord.deptleader        ;
    asSources.Cells[6,icount+1]  := Precord.useflag             ;
    asSources.Cells[7,icount+1]  := Precord.stransflag         ;
    asSources.Cells[8,icount+1]  := Precord.lieover              ;
    asSources.Cells[9,icount+1]  := Precord.stimestamp       ;
    asSources.Cells[10,icount+1] := Precord.smodifyflag     ;
    asSources.Cells[11,icount+1] := Precord.scorpcode        ;
    asSources.Cells[12,icount+1] := floattostr(Precord.dtmodify);
    asSources.Cells[13,icount+1] := Precord.sstopflag          ;
    asSources.Cells[14,icount+1] := Precord.smodifycorpcode;
  end;
end;
procedure TfrmmBase.pclearPdept(dept: Tdept);
begin
  dept.deptno             := '';
  dept.deptname        := '';
  dept.secondname    := '';
  dept.deptaddr          := '';
  dept.depttel             := '';
  dept.deptleader       := '';
  dept.useflag            := '';
  dept.stransflag        := '';
  dept.lieover             := '';
  dept.stimestamp      := '';
  dept.smodifyflag     := '';
  dept.scorpcode        := '';
  dept.dtmodify          := 0 ;
  dept.sstopflag          := '';
  dept.smodifycorpcode := '';
end;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值