The crash is not in that code, it's on a couple other events which are triggered by a mouse-click or changes in the FilesListBox items or in the selected one's index.
In those events he was accessing the Items of the FileListBox with the list's own ItemIndex without checking first whether it actually pointed to an Item: Result? An exception when it doesn't.
It's easy to see: download the code from
this post, compile it as-is, without changes and run it. Then click in the FilesListBox, which will probably be empty because the path is hard-coded to a particular one in the OP's machine.
The BOOM! is almost instantaneous
That said, it doesn't realy explains why it happened also when clicking a real item.
That is a little strange and I'll reserve some time to investigate a little more deeply.