掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
仮想リストビューの使い方 (ID:25783)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
まことさんありがとうございます。 もう一度調べ直して、こちらのサイトを参考にある程度動くようなのを作ってみました。 http://www.occn.zaq.ne.jp/maekawa/delphitip/index.html#c031 それで、下記のコードを書いてみましたが、SubItemに検索したファイルのファイルパスを表示したいのですが、やり方がよくわからないのでアドバイスをお願いします。 unit Unit0; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls; type TForm0 = class(TForm) Button1: TButton; Edit1: TEdit; ListView1: TListView; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListView1Data(Sender: TObject; Item: TListItem); private { Private 宣言 } vListViewItems : TList; procedure FileFind(const S: String); public { Public 宣言 } end; var Form0: TForm0; implementation {$R *.dfm} procedure TForm0.Button1Click(Sender: TObject); var S: String; begin vListViewItems.Clear; S := Edit1.Text; if IsDelimiter('\', S, Length(S)) then SetLength(S, Length(S) - 1); FileFind(S); end; procedure TForm0.FileFind(const S: String); var SR: TSearchRec; NewListItem: TListItem; begin if FindFirst(S + '\*.*', faAnyFile, SR) = 0 then begin repeat if (SR.Name <> '.') and (SR.Name <> '..') then if (SR.Attr and faDirectory) <> 0 then begin FileFind(S + '\' + SR.Name); NewListItem := TListItem.Create(ListView1.Items); NewListItem.Caption := SR.Name; vListViewItems.Add(NewListItem); end else begin NewListItem := TListItem.Create(ListView1.Items); NewListItem.Caption := SR.Name; vListViewItems.Add(NewListItem); end; ListView1.Items.Count := vListViewItems.Count; until FindNext(SR) <> 0; FindClose(SR); end; end; procedure TForm0.FormCreate(Sender: TObject); begin vListViewItems := TList.Create; Edit1.Text := 'C:\text' end; procedure TForm0.ListView1Data(Sender: TObject; Item: TListItem); begin Item.Caption := TListItem(vListViewItems[Item.index]).Caption; end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.