2010-05-21

TListView Move

some thing different from the K-Top

function ListMove(var aList: TListView; aIndexSrc, aIndexTag: Integer): Boolean;
var
  vTempItem, vNewItem, vSrcItem: TListItem;
begin
  Result := False;
  if aIndexSrc = aIndexTag then
    Exit;

  aList.SortType := stNone;
  vSrcItem := aList.Items[aIndexSrc];
  vTempItem := TListItem.Create(aList.Items);
  try
    vTempItem.Assign(vSrcItem);
    vNewItem := aList.Items.Insert(aIndexTag);
    vNewItem.Assign(vTempItem);
    vSrcItem.Delete;
    Result := True;
  finally
    vTempItem.Delete;
  end;
end;
TListView

沒有留言: