Possible Duplicate:
Delphi: Shift-Up and Shift-Down in the Listview
Hi I have a list view and I want to be able to move the selected item / items up开发者_开发问答 and down the list using buttons but cannot figure out how to do this, Could someone give me an example
many thanks
Colin
procedure Tfrprodetile.ExchangeItems(lv: TListView; const i, j: Integer);
var
tempLI: TListItem;
begin
lv.Items.BeginUpdate;
try
tempLI := TListItem.Create(lv.Items);
tempLI.Assign(lv.Items.Item[i]);
lv.Items.Item[i].Assign(lv.Items.Item[j]);
lv.Items.Item[j].Assign(tempLI);
tempLI.Free;
finally
lv.Items.EndUpdate
end;
end;
and for use :
move down :
ExchangeItems(lst_detile,lst_detile.Selected.Index,lst_detile.Selected.Index+1);
move up :
ExchangeItems(lst_detile,lst_detile.Selected.Index,lst_detile.Selected.Index-1);
note that "lst_detile" is name of my listview
good day !
精彩评论