Salve a tutti...
Devo implementare il Drag&Drop da un DataGridView con il Multiselect impostato a True verso un TreeView. Il codice che ho scritto funziona, ha solo un problema, se ci sono più righe selezionate nel DataGridView mi applica il Drag&Drop solo alla riga da cui parte il trascinamento perchè nel momento in cui clicco sul DataGridView per iniziare il Drag la selezione cambia, si deselezionano tutte le righe e rimane selezionata solo quella su cui è avvenuto il Click..
Come posso risolvere????![]()
Codice:
Grazie mille in anticipo.....codice:Private Sub GridDoc_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GridDoc.MouseMove If e.Button = Windows.Forms.MouseButtons.Left And GridDoc.SelectedRows.Count > 0 Then GridDoc.DoDragDrop(GridDoc.SelectedRows, DragDropEffects.Copy) End If End Sub Private Sub Tree_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Tree.DragOver e.Effect = DragDropEffects.Copy Dim pt As Point = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y)) nodoDrop = Tree.GetNodeAt(pt) Tree.SelectedNode = nodoDrop If nodoDrop.Level = 0 Then e.Effect = DragDropEffects.None ElseIf nodoDrop.ImageIndex <> 0 Then e.Effect = DragDropEffects.None Else e.Effect = DragDropEffects.Copy End If s = e.Data.GetData(System.Windows.Forms.DataFormats.StringFormat) MsgBox(s) End Sub Private Sub Tree_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Tree.DragDrop s = e.Data.GetData(System.Windows.Forms.DataFormats.StringFormat) MsgBox(s) Dim risp As MsgBoxResult risp = MsgBox("Archiviare i documenti selezionati in """ & nodoDrop.Text & """?", MsgBoxStyle.YesNo + MsgBoxStyle.Question) If risp = MsgBoxResult.Yes Then Archivia() End If End Sub Sub Archivia() caricaCampi = False Me.Cursor = Cursors.WaitCursor Dim doc As New clsDOC() doc.nodo = Tree.SelectedNode.Name Dim where As String = "" numVis -= GridDoc.SelectedRows.Count For Each drv In GridDoc.SelectedRows where += "IDDOC=" & drv.Cells(0).Value & " OR " filtro += " IDDOC<>" & drv.Cells(0).Value & " AND " Next where = where.Remove(where.Length - 4, 4) doc.setArchivio(where) filtro = filtro.Remove(filtro.Length - 5, 5) dsDOC.Tables(0).DefaultView.RowFilter = filtro GridDoc.DataSource = dsDOC.Tables(0).DefaultView TestoColonneDOC() caricaCampi = True BoxDoc.Text = "Documenti [Risultato della Ricerca: " & numVis & " Documenti]" Me.Cursor = Cursors.Default End Sub

Rispondi quotando
