德尔福 – VitrtualStringTree.如何Drag’n’Drop到ROOT水平?
发布时间:2020-12-14 00:53:30 所属栏目:Linux 来源:网络整理
导读:有一棵树: ROOT – VirtualStringTree(你看不到它,TVirtualStringTree.RootNode) 我的根节点1 我的根节点2 第二节点1 第二节点2 第二节点3 我的根节点3 我可以Drag’n’Drop“我的根节点3”到任何可见节点,但我不能将它返回到defaut位置,到树的根级别. 我试
有一棵树:
ROOT – VirtualStringTree(你看不到它,TVirtualStringTree.RootNode) >我的根节点1 >第二节点1 >我的根节点3 我可以Drag’n’Drop“我的根节点3”到任何可见节点,但我不能将它返回到defaut位置,到树的根级别. 我试着这样: //Part of code from OnDragDrop Event of VirtualStringTree if (Sender.DropTargetNode = Sender.RootNode) then begin for i := 0 to high(Nodes) do begin LinksTree.MoveTo(Nodes[i],Sender.DropTargetNode,Attachmode,False); end; end; 我把鼠标放到了无处,但没有任何反应.在DragOver中,如果DropTarget是VST.RootNode,则接受drop to root. 谁知道,如果我将鼠标拖动到组件的空白区域,如何将节点删除到VST.RootNode? 解决方法
您还没有显示您的代码,但基本上,当您的OnDragDrop事件方法的(drop)Mode参数等于dmNowhere时,您只需要为MoveTo方法调用使用正确的(attach)Mode参数,这表示用户只是将节点删除到树的空白区域.我假设你有一个像下面的代码来确定你的OnDragDrop事件方法中的附加模式:
var ... AttachMode: TVTNodeAttachMode; begin ... // the Mode here is a drop mode parameter case Mode of dmNowhere: AttachMode := amNoWhere; // <- where this stands for no move ... end; ... end; 如果是这样,你可以告诉树附加节点,例如如果丢弃模式为dmNowhere,则将附加模式更改为amAddChildLast作为最后一个子节点: var ... AttachMode: TVTNodeAttachMode; begin ... // the Mode here is a drop mode parameter case Mode of dmNowhere: AttachMode := amAddChildLast; // <- attach node as a last child ... end; ... end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |