TListItemsInsert (Delphi)
Description
The following example inserts a list item before the selected item in the list view. Place a TButton, a TEdit, and a TListView on the form.
Code
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;
Uses
- Vcl.ComCtrls.TListItems.Insert ( fr | de | ja )
- Vcl.ComCtrls.TCustomListView.Selected ( fr | de | ja )
- Vcl.ComCtrls.TListItem.Index ( fr | de | ja )