容易implementation{$R *.DFM}procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbLeft then begin Listbox1.DragMode := dmManual; Listbox1.BeginDrag(False,-1); end; end;procedure TForm1.Label1DragDrop(Sender, Source: TObject; X, Y: Integer); begin if (Sender is TLabel) and (Source is TListBox) then begin with Sender as Tlabel do begin Font := (Source as Tlistbox).Font; Color := (Source as TlistBox).Color; Caption := (Source as TlistBox).Items[(Source as TlistBox).ItemIndex] end; end; end;procedure TForm1.Label1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source is TLIstBox; end; procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source is TLIstBox; end; procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); begin With (Sender as TTreeView) do begin GetNodeAt(X,Y).Text := (Source as TListBox).Items[(Source as TlistBox).ItemIndex]; end; end; procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); begin With (Sender as TTreeView) do begin ItemS.AddChild (GetNodeAt(X,Y),(Source as TListBox).Items[(Source as TlistBox).ItemIndex]);end;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
Listbox1.DragMode := dmManual;
Listbox1.BeginDrag(False,-1);
end;
end;procedure TForm1.Label1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (Sender is TLabel) and (Source is TListBox) then
begin
with Sender as Tlabel do
begin
Font := (Source as Tlistbox).Font;
Color := (Source as TlistBox).Color;
Caption := (Source as TlistBox).Items[(Source as TlistBox).ItemIndex]
end;
end;
end;procedure TForm1.Label1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source is TLIstBox;
end;
procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source is TLIstBox;
end;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
With (Sender as TTreeView) do
begin
GetNodeAt(X,Y).Text := (Source as TListBox).Items[(Source as TlistBox).ItemIndex];
end;
end;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
With (Sender as TTreeView) do
begin
ItemS.AddChild (GetNodeAt(X,Y),(Source as TListBox).Items[(Source as TlistBox).ItemIndex]);end;