Delphi-Help

  • Increase font size
  • Default font size
  • Decrease font size
Главная Статьи Окно списка (ListBox) Как в TListBox перетаскивать items?

Как в TListBox перетаскивать items?

Оцените материал
(0 голосов)

Как в TListBox перетаскивать items?

В свойстве ListBoxa устанавливаем DragMode := dmAutomatic

procedure  TForm1.ListBox1DragOver(Sender,  Source:  TObject;  X,  Y:  Integer;
     State:  TDragState;  var  Accept:  Boolean);
 begin
     Accept  :=  True;
 end;

procedure  TForm1.ListBox1DragDrop(Sender,  Source:  TObject;  X,  Y:  Integer);
 var
     NewIndex  :  Integer;
 begin
     with  Sender  as  TListBox  do  begin
         NewIndex  :=  ItemAtPos(Point(X,Y),  True);
         Items.Move(ItemIndex,  NewIndex);
         ItemIndex:=  NewIndex;
     end;
 end;

Авторизация



Счетчики