本文整理自网络,侵删。
delphi如何把一个文本列表添加到TListBox并避免重复项
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const
FilePath = 'c:\temp\Test.txt';
var
List: TStringList;
begin
List := TStringList.Create;
List.Sorted := True;
List.Duplicates := dupIgnore;
List.LoadFromFile(FilePath);
ListBox1.Items.Assign(List);
List.Free;
end;
end.
相关阅读 >>
检测是否按下键盘或鼠标,如果超过5分钟没有操作则认为用户已经离开
Delphi 新版 thttpclient组件同步下载文件方法
Delphi winapi: getnextwindow - 获取指定窗口z上或z下的窗口的句柄
更多相关阅读请进入《Delphi》频道 >>