Solved

TreeView Component

Posted on 1998-12-16
1
302 Views
Last Modified: 2009-07-29
I am trying to drag a TTreeNode from one TTreeView component to another using the onDragDrop event. I have set the DragMode to dmAutomatic for both components but at run time when I select a node, it seems to picking up the TTreeView component itself rather than the selected node.

So, as soonas I began dragging, the cursor changes to DragNoDrop preventing the onDragDrop event from occuring.

Have, I missed some vital property setting? I am using the standard code provided in the help for the OnDragDrop event, but I can't get the event to go off.

Lee Berry
0
Comment
Question by:leeberry2
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 100 total points
ID: 1351341
When you set your Drag mthod to dmAutomatic, you'll have to provide some extra code to make the control accept the drag. This is done by this example:

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept:= True;
end;


You will ofcourse have to to this on both TreeViews, but then it will work allright.

Regards,
Williams

BTW: If you are trying to use drag and drop with files, this will need special handling.. then use the components on www.melander.dk, they provide all the functions you'll need for that.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now