Как в TListBox перетаскивать items?
В свойстве ListBox’a устанавливаем 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;
|