开发者

Delphi Listview move items up / down with buttons [duplicate]

This question already has answers here: Closed 11 years ago.

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 !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜