Mirror

Change the position of a list item in a TListView (Views: 100)


Problem/Question/Abstract:

How can I move a list item of a TListView one postion down or up?

Answer:

var
  item: TListItem;
begin
  with lvlist do
  begin
    {preserve item since currentPos will be invalid after next line}
    item := items[currentPos];
    {make a new item and assign to it}
    items.insert(moveToPos).assign(item);
    {old item will now remove itself from the listview}
    item.delete;
  end;
end;

<< Back to main page