views:

261

answers:

3

I want to move tree nodes (db records) in TcxDBTreeList by dragging, is there a property on this component for this option ?

+1  A: 

Check the OnBeginDragNode event. That looks to be the best place for what you want to do.

yozey
@yozey: onbegindragnode event solved my problem.
dnn
Glad I could help :-).
yozey
+2  A: 

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;
dnn
A: 

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.

moz