Reorder a TlistBox with drag&drop

 



Remember to set set the ListBox's DragMode property to dmAutomatic.

 

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 ;


Back Home Foward