DevExpress>TcxDBTreeList Drag-Drop Tree Nodes (records)
I want to move tree nod开发者_C百科es (db records) in TcxDBTreeList by dragging, is there a property on this component for this option ?
to enable drag-drop records on TcxDbTreeList
write the codes below to events;
onBeginDragNode event
Allow:= True;
onDragOver event
Accept:=True;
set the cxDbTreeList's DragMode Property
DragMode:=dmAutomatic;
Check the OnBeginDragNode event. That looks to be the best place for what you want to do.
I found that I actually had to move the nodes myself:
procedure TForm1.cxDBTreeList1MoveTo(...);
var i:integer;
begin
for i := 0 to Nodes.Count - 1 do
begin
// move the node in the tree
TcxTreeListNode(Nodes[i]).MoveTo(AttachNode, AttachMode);
// change the database to match
UpdateParentForNode(NodeID, NewParentID, SortSpecifier);
end;
Done := True;
end;
It makes a certain amount of sense in the DBTreeView - the grid doesn't really have a good way to know exactly how you want to change the moved row(s). There's probably a sort order to be modified as well as the parent id.
精彩评论