Piki z FileListBox do ListView (tylko nowe)

0

Witam,

Na formie umieściłem komponenty DirectoryListBox, FileListBox oraz ListView.

Za pomocą poniższej procedury dodaję pliki z FileListBoxa do ListView.

Problem polega na tym, że jak ponownie dodam te same pliki to dublują się one z istniejącymi juź w ListView. Jak dodawać tylko nowe pliki? Próbowałem z IndexOf ale nie działa (niezgodność typów).

Procedura:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
NowyPlik: TListItem;
FullName: string;
I: Integer;
begin

for i := 0 to FileListBox1.Items.Count - 1 do
begin
FullName:= ExtractFileName(FileListBox1.items[i]);

begin
NowyPlik := Lista1.Items.Add;
NowyPlik.Caption := FullName; //dodaje nazwe pliku
end;
end;

Jeżeli ktoś ma pomysł jak rozwiązać ten problem to proszę o pomoc.

Pozdrawiam,

Piotr Murawski

//Uzywaj tagow i a nie

0

A jak korzystasz z tego indexof??

0

Witam,

To szło by tak. Ale nie działa

procedure TForm1.BitBtn1Click(Sender: TObject);
var
NowyPlik: TListItem;
FullName: string;
I: Integer;
begin

for i := 0 to FileListBox1.Items.Count - 1 do
begin
FullName:= ExtractFileName(FileListBox1.items[i]);

if Lista1.Items.IndexOf(FullName)>-1 then
ShowMessage('Plik już istnieje')
else
begin
NowyPlik := Lista1.Items.Add;
NowyPlik.Caption := FullName; // dodaje nazwe pliku
end;

end;

Może ktoś wie jak ten problem rozwiązać.

Pozdrawiam,

Piotr Murawski

0

Returns the position of a list item in the list view window.

function IndexOf(Value: TListItem): Integer;

Description

Call IndexOf to determine the position of the list item specified by the Value parameter. IndexOf returns -1 if the list item is not in the list view.


Zrób pętlę przeszukująca TListViewa.

1 użytkowników online, w tym zalogowanych: 0, gości: 1