Delphi-Help

  • Увеличить размер шрифта
  • Default font size
  • Уменьшить размер шрифта

Как в 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;
Login to post comments

Счетчики

счетчик посещений
счетчик посещений