Recent

Author Topic: TListView where to find info on usage  (Read 119 times)

DenPit5

  • New member
  • *
  • Posts: 6
TListView where to find info on usage
« on: December 06, 2018, 12:58:56 pm »
I want to have a list of about ten items that I can get to pop up at the click of a button and then be able select an item from the list.    I have tried TListView component and can get it to display and can select an item from the list but I do not know how to capture the item for further use in the Unit.
Where can I find further Info on usage. ?

lucamar

  • Sr. Member
  • ****
  • Posts: 461
Re: TListView where to find info on usage
« Reply #1 on: December 06, 2018, 01:36:30 pm »
In the documentation, either the one installed with Lazarus or in the CCR (Sourceforge), although it's a little sparse ...

To get the selected item you have to traverse the list Items and, for each TListItem, check whether its Selected property is true. Something like:

Code: Pascal  [Select]
  1. {Untested; intended only as example!}
  2. function GetSelected: TListItem;
  3. var AnItem: TListItem;
  4. begin
  5.   for AnItem in AListView.Items do
  6.     if AnItem.Selected then begin
  7.       Result := AnItem;
  8.       Break;
  9.     end;
  10. end;
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 11..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

wp

  • Hero Member
  • *****
  • Posts: 5118
Re: TListView where to find info on usage
« Reply #2 on: December 06, 2018, 01:56:51 pm »
Maybe this tutorial is helpful: http://forum.codecall.net/topic/74040-basic-working-with-tlistview/. It is for Delphi, but this should not make a big difference.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

DenPit5

  • New member
  • *
  • Posts: 6
Re: TListView where to find info on usage
« Reply #3 on: December 07, 2018, 01:08:21 pm »
Thank You to everyone who replied.   I have found the information that you posted was very Helpful.