Delphi下ListView加载百万数据



var
  Form1: TForm1;
  FileNamestr: string;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    Edit1.Text := OpenDialog1.FileName;
    FileNameStr := Edit1.Text;
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SList.Free;
end;

procedure TForm1.RzListView1Data(Sender: TObject; Item: TListItem);
begin
  with Item do
  begin
    Caption := IntToStr(Item.Index);
    SubItems.Add(SList[Item.Index]);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SList := TStringList.Create;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i: integer;
  st, ed: Cardinal;
begin
  SList.LoadFromFile(FileNameStr);
  st := GetTickCount;
  RzListView1.Items.Count := sList.Count;
  for i := 1 to SList.Count do
  begin
    //SList.Add(IntToStr(i));
    SList.Add(SList.Strings[i]);
  end;
  ed := GetTickCount - st;
  ShowMessage(IntToStr(ed));
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to 9 do
  begin
    RzListView1.Items.BeginUpdate;
    //sList.Strings[i] := '测试!!!!!';
    sList[i] := StringReplace(sList[i], sList.Strings[i], '测试!!!!!', [rfReplaceAll]);
    RzListView1.Items.EndUpdate;
  end;
  sList.Add(sList.GetText);
end;

end.


评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭