K
kusanagi
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我做的一个TTreeView的拖动的例子。
界面上只有一个TTreeView,随便加了些结点,都带有子结点。
var
sourcetreenode: TTreeNode;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
tempnode, targetTreeNode: TTreeNode;
begin
tempnode:= treeview1.Items.AddChild(treeview1.droptarget, '');
tempnode.Assign(sourcetreenode);
sourcetreenode.Free;
end;
procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
accept:= True;
end;
procedure TForm1.TreeView1StartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
sourcetreenode:= treeview1.Selected;
end;
结果是将一个带子结点的结点拖动到另一个结点做为其子结点时,新子结点有展开的符号可是展不开。
恳请大虾门指正
界面上只有一个TTreeView,随便加了些结点,都带有子结点。
var
sourcetreenode: TTreeNode;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
tempnode, targetTreeNode: TTreeNode;
begin
tempnode:= treeview1.Items.AddChild(treeview1.droptarget, '');
tempnode.Assign(sourcetreenode);
sourcetreenode.Free;
end;
procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
accept:= True;
end;
procedure TForm1.TreeView1StartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
sourcetreenode:= treeview1.Selected;
end;
结果是将一个带子结点的结点拖动到另一个结点做为其子结点时,新子结点有展开的符号可是展不开。
恳请大虾门指正