Track tree node during drag operation? MouseMove doesn't fire during drag??

S

Samuel R. Neff

I have a typical TreeView/ListView combo and can drag from the
ListView to the TreeView.

I'd like to select the TreeView node that is the target of the drag
operation as the ListView items are dragged around the tree. I
haven't found a way to do this. Apparently TreeView.MouseMove isn't
fired during the drag operation.

Any suggestions or examples?

Thanks,

Sam
 
P

Peter Huang [MSFT]

Hi

You may take a look at the link below.
307968 How To Add TreeView Drag-and-Drop Functionality in a Visual C# .NET
http://support.microsoft.com/?id=307968

private void treeView_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)

In the DragDrop's eventargs, the e.x and e.y will tell us the drop point.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Samuel R. Neff

That's fine for the drop point, but I want to hot track the tree nodes
as the user moves the mouse around the tree the way windows explorer
shows the target folder when you drag files from the listview to the
tree. MouseMove doesn't fire and HotTrack doesn't work during a drag
operation.

Sam
 
P

Peter Huang [MSFT]

Hi

I think you may try to handle the DragOver event.
e.g.
TreeNode lastNode = null;
private void treeView1_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{
if(lastNode!=null)
lastNode.BackColor=Color.White;
Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt);
if (DestinationNode!=null)
{
DestinationNode.BackColor = Color.Red;
lastNode = DestinationNode;
}
}

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top