Einzelnen Beitrag anzeigen

scp

Registriert seit: 31. Okt 2003
1.120 Beiträge
 
Delphi 7 Personal
 
#3

Re: Per Drag&Drop Items aus ner Listbox an ne andere &am

  Alt 5. Nov 2003, 11:32
Beim Form und bei den Listboxen muss Dragmode auf dmAutomatic gestellt werden. Der Rest geht so:

Delphi-Quellcode:
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  If (Source.ClassName = 'TListBox') then
    begin
      ListBox1.Items.Add( TListBox(Source).Items[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
  If (Source.ClassName = 'TListBox') then
    Accept := true;
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  If (Source.ClassName = 'TListBox') then
    Accept := true;
end;

procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  If (Source.ClassName = 'TListBox') then
    begin
      TListBox(Source).Items.Delete(TListBox(Source).ItemIndex);
    end;
end;
  Mit Zitat antworten Zitat