设置TreeView的DragMode = dmAutoMatic
procedure TFmMain.TreeLeftDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := False ;
//if (source is TTreeNode) or (Source is TListItem) then
if (source is TTreeView) or (source is TListview) then
Accept := true ;
end;
procedure TFmMain.TreeLeftDragDrop(Sender, Source: TObject; X, Y: Integer);
var
tSrcNode ,tDesNode: TTreeNode ;
tSrcID ,tDesID : Integer ;
sSql : String ;
lSrcItem : TListItem ;
begin
tSrcID := 0 ;tDesID := 0 ;
tDesNode := TTreeview(Sender).GetNodeAt(X,Y);
if Source is TTreeview then
begin
TTreeview(Sender).Items.BeginUpdate;
tSrcNode := TTreeview(Source).Selected ;
tSrcNode.Moveto(tDesNode,naAddChild);
TTreeview(Sender).Items.EndUpdate;
end
end;