TListViewItem

Source: source/classes/tlistvie.prg

Standalone class (used by TListView)

TListViewItem represents a single item in a TListView control. Each item can display text, an image from an image list, and be assigned to a group for categorized views. Items support tooltips, indentation, and checked state.

Key DATA Members

DATATypeDescription
cTextCharacterItem display text
nImageNumericIndex into the image list (0 = no image)
nGroupNumericGroup ID this item belongs to
nItemNumericItem index within the list view

Methods

MethodDescription
New( oParent )Create a new item associated with a TListView
Create( oParent )Insert the item into the list view
SetText( cText ) / GetText()Change or retrieve item text
SetImage( nImage ) / GetImage()Change or retrieve image index
SetGroup( nGroup )Assign the item to a group

TListViewGroup

Standalone class (used by TListView)

Defines a visual grouping header within a grouped list view. Groups organize items into collapsible categories.

DATATypeDescription
cHeaderCharacterGroup header text
nGroupIdNumericUnique group identifier
nStateNumericState: normal (0), collapsed (1), hidden (2)
MethodDescription
New( oParent )Create a group
Create( oParent )Insert the group into the list view
SetState( nState )Collapse, expand, or hide the group

Example: Grouped List View

#include "FiveWin.ch"
function Main()
   local oWnd, oList, oGrp1, oGrp2, oItem
   DEFINE WINDOW oWnd TITLE "Grouped ListView" SIZE 500, 400
   @ 10, 10 LISTBOX oList FIELDS "" OF oWnd SIZE 460, 350
   oList:EnableGroupView()
   oGrp1 := TListViewGroup():New( oList )
   oGrp1:cHeader := "Fruits"; oGrp1:Create()
   oGrp2 := TListViewGroup():New( oList )
   oGrp2:cHeader := "Vegetables"; oGrp2:Create()
   oItem := TListViewItem():New( oList )
   oItem:cText := "Apple"; oItem:nGroup := oGrp1:nGroupId; oItem:Create()
   ACTIVATE WINDOW oWnd CENTERED
return nil

Notes

See Also