Get the seleted text from a TListbox? lazarus / 61-Beginners ---------------------------------------------------------------------- heebiejeebies · 2021-01-10 23:16 Hi all, I need to change the caption of a TStaticText to match the text that is selected in a TListBox.  I've tried every variation of the below that I can possibly think of, with no luck: 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.ListBox1ASelectionChange(Sender: TObject; User: boolean);begin TitleBox1.Caption := ListBox1A.Selected;end; Which raises a follow-up question: how do you find the names of these sorts of properties?  The wiki lists all the basic properties that can be viewed/changed through the inspector, but I can't seem to find the property names for the things like this - i.e. the current selection of the listbox.  If there were a list of them somewhere then I probably wouldn't have had to ask this question.  Does that exist anywhere?  Coz I feel like everyone else on this board has some secret initiation (possibly with an elaborate handshake) that I'm not privileged to possess. ---------------------------------------------------------------------- Zath · 2021-01-10 23:24 The best way to see what properties etc. you can test for is to type the name of the component, press the . separator and wait for IDE to give you a list of methods, properties and procedures. ---------------------------------------------------------------------- Zath · 2021-01-10 23:39 As for your main issue, see this thread. https://forum.lazarus.freepascal.org/index.php?topic=16404.0 Just what you need. ---------------------------------------------------------------------- speter · 2021-01-10 23:41 Handshake authentication failure. Newbie mode ON. Greetings heebiejeebies, There are probably easier ways, but this works: 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.ListBox1SelectionChange(Sender: TObject; User: boolean);var  a : byte;begin  for a := 0 to listbox1.items.count-1 do    if listbox1.selected[a] then      StaticText1.caption := listbox1.items[a];end; In addition to Zath's helpful comment; remember "google is your friend" When I do a search for tlistbox, the first result is: https://wiki.lazarus.freepascal.org/TListBox which gives a good overview of the component. cheers S. ---------------------------------------------------------------------- jamie · 2021-01-10 23:43 Why not do it the correct way? SomeCaption := ListBox.Items[ListBox.ItemIndex]; At least that will get you started.. But I wonder if you are actually trying to get the actual high lighted text from a multi-Select mode List box ? Because there is another way for that too Like the ListBox.GetSelectedText which equals a string ! ---------------------------------------------------------------------- heebiejeebies · 2021-01-11 00:02 Thank you everyone!  That's solved it.  I did look at the wiki by the way - but couldn't find anything in there that answered the question.  I'm still a little confused by the whole Pascal syntax thingamajig  - coming from programming in LiveCode, I just expected it to have a logical property name like Listbox.SelectedItemName.  Darn you real programmers - why do you have to make everything so complicated?  Anyway, thanks everyone - I'll nominate you all for canonisation. ---------------------------------------------------------------------- heebiejeebies · 2021-01-11 03:36 Quote from: jamie on January 11, 2021, 12:43:30 amLike the ListBox.GetSelectedText which equals a string ! Just saw your edit.  Thank you!  So there is a simple, logical way to do it after all  *Burns incense in front of an effigy of Jamie*