RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TListItems.Item Property

Lists all list items managed by the TListItems object.

Pascal
property Item [Index: Integer]: TListItem;
C++
__property TListItem Item[int Index];

Use Item to directly access a list item, given its position in the list view. The first item has an index of 0, the second an index of 1, and so on.  

C++ Examples: 

 

/*
The following code uses Item to add the labels of all child
nodes of the selected node to a list box when a button is
clicked.  This example requires a button, a listbox, and a
populated treeview.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 0; i < TreeView1->Selected->Count; i++)
    ListBox1->Items->Add(TreeView1->Selected->Item[i]->Text);
}

 

Delphi Examples: 

{
The following code uses Item to add the labels of all child
nodes of the selected node to a list box when a button is
clicked.  This example requires a button, a listbox, and a
populated treeview.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  I : Integer;
begin
  for I := 0 to (TreeView1.Selected.Count - 1) do
    ListBox1.Items.Add(TreeView1.Selected.Item[I].Text);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!