Как в TListBox пеpетаскивать Items (Drag&Drop)
Как в TListBox пеpетаскивать Items (Drag&Drop)
Как в TListBox пеpетаскивать Items (Drag&Drop) DragMode := dmAutomatic; {OnDragOver} procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := True; end; {OnDragDrop} 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; Или вот так: Drag and Drop in TListBox procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer); begin with (Sender as TListBox) do Items.Move(ItemIndex,ItemAtPos(Point(x,y),True)); end; procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := (Sender=Source); end;