Link to home
Start Free TrialLog in
Avatar of xpher
xpher

asked on

FileListBox - Search - Sort

I am displaying filenames in FileListBox (obvious I suppose) my file names are peoples names ie MR A PERSON.jpg. I have no problem displaying without file extension but what I would like to do is have the list sorted alphabetically by surname (keeping name format same as above) and I would also like to search by surname and return item index.

I know this sounds like two questions in one but it is all tied together so I couldn't split.

Many thanks
Chris
Avatar of chrb
chrb

You could make your own sub class of the TFileListBox where you override ReadFilesNames and sort the Items list

TMyFileListBox = class(TFileListBox)
protected
  procedure ReadFileNames; override;
end;

procedure TMyFileListBox.ReadFilesName;
begin
  inherited;
  {Here you sort the list}
end;

And you could add your own method IndexOf or so to search on surname.

Christian
ASKER CERTIFIED SOLUTION
Avatar of kubeerja
kubeerja

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xpher

ASKER

Your getsurname function I don't quite follow. Bearing in mind that before the surname it could be
Mrs A Surname
Ms A Surname
Mr A Surname
A Surname

Chris
this function will work with all the cases you list and get the surname.
the sort will work on the surname only and not on the surname and first name in the same time