Board index » delphi » How to delete double filenames in my FileListBox?

How to delete double filenames in my FileListBox?

Hi there!

I have a FileListBox and put many files to it. In my case it should
not be possible to put one specific file more than one time into the
FileListBox.
My problem is to delete entries which appears more than one time.
So each filename is unique and should be shown just one time.

1. How can I delete double filenames in my FileListBox?

And here another question :
2. Is there a possibility to select one specific entry (filename) in
the
   FileListBox without clicking on it?

Thanks you so much for your help!

 Hans

 

Re:How to delete double filenames in my FileListBox?


On 12 Nov 2001 12:01:41 -0800, h.h...@gmx.de (Hans Hermann) wrote:

Quote
>Hi there!

>I have a FileListBox and put many files to it. In my case it should
>not be possible to put one specific file more than one time into the
>FileListBox.
>My problem is to delete entries which appears more than one time.
>So each filename is unique and should be shown just one time.

I'm going to presume we're talking about the Delphi TFileListBox here.

Quote
>1. How can I delete double filenames in my FileListBox?

Probably the simpler thing is not to permit adding duplicates in the
first place; when you go to add a filename, check whether the name
already exits:

  if FileListBox1.Items.IndexOf(NewFile) = -1 then
    { no such file already in list so go ahead and add it }
    FileListBox.Items.Add(NewFile);
  { else it does exist so do nothing }

Quote
>And here another question :
>2. Is there a possibility to select one specific entry (filename) in
>the FileListBox without clicking on it?

  FileListBox1.ItemIndex := DesiredItem;

Where DesiredItem is the numeric index of the item you want to
highlight (note that the items are numbered from 0 to Items.Count-1)

HTH

Stephen Posey
slpo...@concentric.net

Other Threads