filename is one behind selection in filielistbox? lazarus / 31-LCL ---------------------------------------------------------------------- Ruptor · 2014-02-26 13:10 When I click a file in the filelistbox and read the file name using this code the filename is one behind the actual selection. on the first file clicked the edit box is blank then on the second file clicked the edit box shows the first file clicked. I don't understand what is going on. Can anyone explain it to me? Code: [Select]procedure TForm1.FileListBox1SelectionChange(Sender: TObject; User: boolean); begin   Edit1.text:=extractFileName(FileListbox1.filename); end; ---------------------------------------------------------------------- engkin · 2014-02-26 14:40 You are using the wrong event: Quote from: Ruptor on February 26, 2014, 02:10:19 pmprocedure TForm1.FileListBox1SelectionChange(Sender: TObject; User: boolean); begin   Edit1.text:=extractFileName(FileListbox1.filename); end; Use OnChange instead. ---------------------------------------------------------------------- Ruptor · 2014-02-26 21:16 It works with onchange thanks. I would have thought onselesctionchange would point to the latest selection and not the previous one though.