Duplicate listbox content: is this good? lazarus / 31-LCL ---------------------------------------------------------------------- dietmar · 2021-10-02 11:25 Hi, I have a listbox which gets filled by the user with filenames. Since they can be quite long, I just write MinimizeName(filename) into the listbox. On the other hand, when working with the values, I need access to the whole long, complete filenames... So my idea was to place a hidden listbox onto the form and to fill that parallel to the visible listbox, but with the real filenames, not MinimizeName. Is that good style? Or has anyone a better idea for this problem? Thx, --Dietmar ---------------------------------------------------------------------- alpine · 2021-10-02 11:39 Quote from: dietmar on October 02, 2021, 01:25:36 pmHi, I have a listbox which gets filled by the user with filenames. Since they can be quite long, I just write MinimizeName(filename) into the listbox. On the other hand, when working with the values, I need access to the whole long, complete filenames... So my idea was to place a hidden listbox onto the form and to fill that parallel to the visible listbox, but with the real filenames, not MinimizeName. Is that good style? Or has anyone a better idea for this problem? Thx, --Dietmar You can use an additional TStringList, not a whole list box in order to use it Items property. ---------------------------------------------------------------------- wp · 2021-10-02 12:24 The TListbox of Delphi has a virtual mode in which the listbox does not store the strings by itself but gets them from outside. This would be what you need, but in Lazarus this is not yet implemented. If you do not insist on a TListbox you could switch to a TListView which can be virtualized. It means - Store the strings in a StringList (or an array, or whatever suites you) - Tell the ListView the count of the strings (ListView.Items.Count := ) - Set TListView.Ownerdata to true to switch to virtual mode - Write an event handler for the ListView's OnData which passes a string from the StringList/Array/... to the specified Listview's item. Here you can call MinimizeName to shorten the string - the original string in the StringList/Array is unaffected. Please study the attached demo, it contains lots of comments. Change the width of the form at runtime to see MinimizeName in action. And click on a list item to verify that the original full filename is returned although it is shortened in the ListView. ---------------------------------------------------------------------- dietmar · 2021-10-02 12:39 Cool... thanks a lot! --Dietmar ---------------------------------------------------------------------- Bart · 2021-10-02 13:07 Make the listbox ownerdrawn, then draw the items with MiniMizeName. Notice that what you see in the list is only the visual representation, Items will still conatin the full name! Bart