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
| DATA | Type | Description |
|---|---|---|
cText | Character | Item display text |
nImage | Numeric | Index into the image list (0 = no image) |
nGroup | Numeric | Group ID this item belongs to |
nItem | Numeric | Item index within the list view |
Methods
| Method | Description |
|---|---|
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.
| DATA | Type | Description |
|---|---|---|
cHeader | Character | Group header text |
nGroupId | Numeric | Unique group identifier |
nState | Numeric | State: normal (0), collapsed (1), hidden (2) |
| Method | Description |
|---|---|
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
- Call
oList:EnableGroupView()before adding groups. - Items are added to
oList:aItemsupon creation. Groups go intooList:aGroups. - The
nGroupproperty on an item must match a group'snGroupId.