Drag and Drop em dois ListBox

Delphi

09/04/2004

Olá, como posso fazer isso?

Obrigado


Ninjapan

Ninjapan

Curtidas 0

Respostas

Aroldo Zanela

Aroldo Zanela

09/04/2004

Colega,

- Solte dois ListBox no formulário (ListBox1 e ListBox2) e altere a propriedade DragMode para dmAutomatic;

- Adicione o código abaixo nos eventos do segundo ListBox:

procedure TForm1.ListBox2DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TListBox;
end;

procedure TForm1.ListBox2DragDrop(Sender, Source: TObject; X, Y: Integer);
var aListBox: TListBox;
begin
  aListBox := Source as TListBox;
  (Sender as TListBox).Items.Add(aListBox.Items[aListBox.ItemIndex]);
end;



GOSTEI 0
POSTAR