Lazarus

Programming => General => Topic started by: DenPit5 on December 06, 2018, 12:58:56 pm

Title: TListView where to find info on usage
Post by: DenPit5 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. ?
Title: Re: TListView where to find info on usage
Post by: lucamar on December 06, 2018, 01:36:30 pm
In the documentation, either the one installed with Lazarus or in the CCR (Sourceforge) (http://lazarus-ccr.sourceforge.net/docs/lcl/comctrls/tlistview.html), 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;
Title: Re: TListView where to find info on usage
Post by: wp 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.
Title: Re: TListView where to find info on usage
Post by: DenPit5 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