Recent

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

DenPit5

  • New Member
  • *
  • Posts: 21
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

  • Hero Member
  • *****
  • Posts: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

wp

  • Hero Member
  • *****
  • Posts: 11855
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.

DenPit5

  • New Member
  • *
  • Posts: 21
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.

 

TinyPortal © 2005-2018