RAD Studio VCL Reference
|
Indicates the position of the list item in the TListItems collection.
property Index: Integer;
__property int Index;
Use Index to locate the item in the list view. The first item has an index of 0, the second item has an index of 1, and so on.
C++ Examples:
/* The following example inserts a list item after the selected item in the list view. Place a TButton, a TEdit and a TListView in the form. */ void __fastcall TForm1::Button1Click(TObject *Sender) { TListItem *InsertItem; if (ListView1->Selected == NULL) return; InsertItem = ListView1->Items->Insert(ListView1->Selected->Index); InsertItem->Caption = Edit1->Text; } void __fastcall TForm1::FormCreate(TObject *Sender) { TListItem *ListItem; ListView1->ViewStyle = vsList; ListItem = ListView1->Items->Add(); ListItem->Caption = "Apples"; ListItem = ListView1->Items->Add(); ListItem->Caption = "Oranges"; ListItem = ListView1->Items->Add(); ListItem->Caption = "Pears"; }
Delphi Examples:
{ The following example inserts a list item after the selected item in the list view. Place a TButton, a TEdit and a TListView in the form. } procedure TForm1.Button1Click(Sender: TObject); var InsertItem : TListItem; begin with ListView1 do begin if (Selected = nil) then exit; InsertItem := Items.Insert(Selected.Index); end; InsertItem.Caption := Edit1.Text; end; procedure TForm1.FormCreate(Sender: TObject); var ListItem : TListItem; begin ListView1.ViewStyle := vsList; ListItem := ListView1.Items.Add; ListItem.Caption := 'Apples'; ListItem := ListView1.Items.Add; ListItem.Caption := 'Oranges'; ListItem := ListView1.Items.Add; ListItem.Caption := 'Pears'; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|