THashedStringList - do we have it still? lazarus / 21-General ---------------------------------------------------------------------- Nicole · 2025-04-17 17:08 This is done - a method calls a function - this function does a query with a unknown count of results and returns them at the moment in a THashedStringList. Each "hit" has naturally a primary key, which is known by the function - the calling method writes the function's results (=the THasedStringList) into a TListView - the user clicks one line of the TListView and triggers the ListView's click-Event. How to get the primary key into the ListView's click-Event?! My idea was, that it shall be saved in the returned HashStringList. Unfortunately I neither know, how to key in the primary keys as values. Nor do I know, how to grab those values, after having added the words to the TListView. In other words: I need a way to get the primary key into the click event of the TListView. I am thankful for any syntax, how to read and write a HasehdStringList. As well as better ways to do it. In the meanwhile I found a better documenation. https://www.freepascal.org/docs- html/fcl/inifiles/thashedstringlist.indexof.html ---------------------------------------------------------------------- cdbc · 2025-04-17 17:22 Hi Hmmm, there's always the 'Data' property of 'TListItem', you can use, it's a pointer so you can put anything in it. It's easily accessible when clicked... Regards Benny ---------------------------------------------------------------------- Nicole · 2025-04-17 17:44 The pointer won't work stable. The database query result is nothing, which I dare to trust, the pointer will point there after a while still. ---------------------------------------------------------------------- cdbc · 2025-04-17 17:49 Hi Where should it run off to...?  It doesn't know anybody...  Regards Benny ---------------------------------------------------------------------- Martin_fr · 2025-04-17 17:51 Create your own list from a generic list... Then you can store any data you need, as long as you need. In the ListView, in the "Data" just store the index of the entry in the created list.  (Or store "index + 1", so you can have zero/nil as detectable "not set") ---------------------------------------------------------------------- Nicole · 2025-04-17 18:14 How to? The first step is: set the pk in the function, this should be: result.     ????????   :=primaryKey; second get it to the ListView1 by ListView1.???????????  :=HashedStrinList1.??? third read it in the ListView1ClickEvent pk:=ListView1.????????? ---------------------------------------------------------------------- Martin_fr · 2025-04-17 18:32 Without running syntax checks... 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 uses fgl;{$modeswitch advancedrecords}type  TMyFooData = record    PKey: TPKeyType; // int / string/ ....    Text: string;    // ... other data     class operator = (Item1, Item2: TMyFooData): Boolean;  end;   TMyList = specialize TFPGList; ////// for each itemvar   Data: TMyFooData;  Lst: TMyList;begin  Data.PKey := ...  Data.Text := the_text;  idx : Lst.Add(Data);  ListView.AddObject(the_text, TObject(PtrUint(idx))); ---------------------------------------------------------------------- Martin_fr · 2025-04-17 18:39 In the click-event you should be able to get the itemindex of the clicked item. and then (something like). 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 idx := ptruint(ListView.items.objects[itemindex]) I am not sure if the property is "items". But afaik/iirc there is an interface to store/retriev objects with each displayed item. ---------------------------------------------------------------------- paule32 · 2025-04-17 18:40 seems that Nicole would like do some documenting stuff ? is'n it ? get in touch with me to extend the people on a project of me (us). ---------------------------------------------------------------------- Thaddy · 2025-04-18 07:53 The items property is default afaik so you can notationally skip it.