Na początku w obu listach ustaw DragMode na dmAutomatic. Następnie ustaw dla nich wspólne procedury DragOver oraz DragDrop :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer); begin If (Source is TListBox) then begin TListBox(Sender).Items.Add(TListBox(Source).Items.Strings[TListBox(Source).ItemIndex]); TListBox(Source).Items.Delete(TListBox(Source).ItemIndex); end; end; procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := True; end; |
Autor: Nakiel