With a TTreeView
setup with DragMode
dmAutomatic
I can use the OnDragDrop
and OnDragOver
events to handle the drag/drop. But I don't want a particular TTreeNode
in the tree to be able to be dragged. I would guess I would need to use dmManual
but I haven't found an example of how to do that and wonder if that is what is required?
So the basic question is, how do you prevent a particular TTreeNode
item from being able to be dragged (it can be a drop target)? If dmManual
, how do you use that mode?
TIA!!
If you want fully exclude drag start, you have to use dmManual
mode, as you wrote, and set BeginDrag
in OnMouseDown
:
if (Button = mbLeft) and
(Treeview1.Selected <> nil) and
(Treeview1.Selected.Text > 'b') then
TreeView1.BeginDrag(True);
In this example node with text='aa'
is not dragged, while node 'cc'
is.
Perhaps sometimes you'll need also change Immediate
to False
and apply Threshold
value (if you need clicks)