RAD Studio VCL Reference
|
Returns the next list item after the StartItem in the specified direction.
function GetNextItem(StartItem: TListItem; Direction: TSearchDirection; States: TItemStates): TListItem;
__fastcall TListItem GetNextItem(TListItem StartItem, TSearchDirection Direction, TItemStates States);
Call GetNextItem to find the next list item after StartItem in the direction given by the Direction parameter. Only items in the state indicated by the States parameter are considered.
C++ Examples:
/* This example demonstrates how to retrieve all selected items in a ListView component and add the Caption of the selected ListItems to a ListBox component. Add a button, a listview, and a listbox to the form. */ 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"; } void __fastcall TForm1::Button1Click(TObject *Sender) { TItemStates selected = TItemStates() << isSelected; TListItem *Item = ListView1->Selected; while (Item){ ListBox1->Items->Add(Item->Caption); Item = ListView1->GetNextItem(Item, sdAll, selected); } }
Delphi Examples:
{ This example demonstrates how to retrieve all selected items in a ListView component and add the Caption of the selected ListItems to a ListBox component. Add a button, a listview, and a listbox to the form. } procedure TForm1.Button1Click(Sender: TObject); var Item: TListItem; begin Item := ListView1.Selected; while Item <> nil do begin ListBox1.Items.Add(Item.Caption); Item := ListView1.GetNextItem(Item, sdAll, [isSelected]); end; 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!
|