var
cNode: TTreeNode;
// 将ListView1的DragMode属性设为dmAutomatic
// 当鼠标经过时响应的事件
procedure TForm1.TreeView1DragOver(Sender, Source: TObject;
X, Y: Integer;
State: TDragState;
var Accept: Boolean);
var
Node: TTreeNOde;
begin
if Source is TListView then
begin
Accept:=True;
// 如施放来自TListView则接受
cNode:=TreeView1.GetNodeAt(x,y);
// 拖放到TreeView上的节点
if cNode=nil then
begin
Accept:=False;
Exit;
end;
end
else
Accept:=False;
end;
// 鼠标放下时响应,加入你需要处理的代码
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin
// 假设你是要在目标节点上建立子节点 //
with Treeview1.Items,ListView1.Selecteddo
begin
AddChild(cNode,Caption);
// 添加Listview1的标题
AddChild(cNode,Subitems.Strings[0]) //添加Listview1的子标题
end;
end;