VCL Delphi

procedure TfrmMain.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if TreeView1.Selected.Level=0 then
Accept:=False;
end;
procedure TfrmMain.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if TreeView1.GetNodeAt(x,y).Level=1 then
TreeView1.Items.Add(TreeView1.GetNodeAt(x,y),TreeView1.Selected.Text)
else
TreeView1.Items.AddChild(TreeView1.GetNodeAt(x,y),TreeView1.Selected.Text);
TreeView1.Selected.Delete;
TreeView1.AlphaSort;
end;
End.