Simulate a click on the first item of a TFileListBox lazarus / 31-LCL ---------------------------------------------------------------------- Roland57 · 2021-03-11 07:30 Hello! I have made a little application for viewing text files of a folder. There is a TFileListBox. When the user clicks on an item (or changes the selected item with keyboard arrows), the file is loaded into a TMemo. I would like that, when the directory changes, the first file of the list to be loaded, as if the user had clicked on the first item. It sounds easy, but I don't find the way to do that. The application is here: https://github.com/rchastain/textview Any other suggestion on this project would be also welcome. Regards. Roland ---------------------------------------------------------------------- Zvoni · 2021-03-11 07:56 Since TFileListBox is descended from TCustomListBox, my money would be either on Property ItemIndex or Property Selected https://lazarus- ccr.sourceforge.io/docs/lcl/stdctrls/tcustomlistbox.selected.html ---------------------------------------------------------------------- Roland57 · 2021-03-11 08:26 Quote from: Zvoni on March 11, 2021, 08:56:47 amSince TFileListBox is descended from TCustomListBox, my money would be either on Property ItemIndex or Property Selected Thank you for your answer. Indeed, this seems to work: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FileListBox1.ItemIndex := 0;  FileListBox1.Click; ---------------------------------------------------------------------- Roland57 · 2021-03-11 08:52 Here is what I did: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.LoadFirstItem;begin  if FileListBox1.Items.Count > 0 then  begin    FileListBox1.ItemIndex := 0;    FileListBox1.Click;  end else    Memo1.Clear;end; Not sure that the organisation of my code be optimal, but it seems to work.