How to HighLight the Drag-Drop Node in TreeView ?


J

jiatiejun

There is DropHighlight prop when DropDrag in VB6,

how to implement in VB.NET or C# ?

thanks
 
Ad

Advertisements

R

Robin Tucker

Use the DragOver event to determine what you are dragging over - (as you
should anyway to determine whether its ok to do so) and then set the current
item as the selected item (something like this - )

Private Sub TreeView_DragOver(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TreeView.DragOver
' Assume we can't drop

' Ok, are we currently over a tree node?

Dim mousePos As Point
mousePos = TreeView.PointToClient(Cursor.Position)

Dim nodeOver As MultiSelectTreeViewNode =
CType(TreeView.GetNodeAt(mousePos), MultiSelectTreeViewNode)

If nodeOver Is Nothing Then
Exit Sub
Else
TreeView.SelectedNode = nodeOver
end if
end sub
 
J

jiatiejun

but the "TreeView.SelectedNode = nodeOver" will fire the After_SelectChanged
events,

I place the fill listview code in this event,

I want not the event happen when Drop-Drap
 
Ad

Advertisements

R

Robin Tucker

Well, yes it will - there is no other way of doing it, unless you store the
current node (nodeOver), change its colour manually then next time you go
into the onDragDrop you change the colour back before storing the new one.
 

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