venerdì 11 aprile 2014

DRAG-DROP SU TREEVIEW

Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
   If Button = vbLeftButton Then ' Signal a Drag operation.
      Draging = True ' Set the flag to true.
      ' Set the drag icon with the CreateDragImage method.
     
      TreeView1.Drag vbBeginDrag ' Drag operation.
   End If
End Sub

Private Sub TreeView1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
   If Draging = True Then
      ' Set DropHighlight to the mouse's coordinates.
      Set TreeView1.DropHighlight = TreeView1.HitTest(x, y)
   End If
End Sub


Private Sub gridMail_DragDrop(Source As Control, x As Single, y As Single)
  Set nodoScelto = TreeView1.SelectedItem
  'se il nodo è livello 3 significa che è un fornitore e quindi lo inserisce subito in lista
  If livelloNodo(nodoScelto) = 3 Then
    aggiungiInGridMail nodoScelto.Text
  End If
 
End Sub