TheWizardofInt Posted January 13, 2005 Posted January 13, 2005 I am trying to drag files from subdirectories in Windows Explorer to Treeview No matter how I code the thing, it says that the drag as no data, and therefore doesn't populate What am I doing wrong here? Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop Dim oNode As New System.Windows.Forms.TreeNode If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", False) Then Try For Each oNode In TreeView1.Nodes oNode.Remove() Next oNode.ImageIndex = 0 ' Closed folder oNode.SelectedImageIndex = 0 oNode.Text = e.Data.GetData(DataFormats.Text).ToString() 'oNode.Text = e.Data.GetData("System.Windows.Forms.TreeNode") TreeView1.Nodes.Add(oNode) oNode.Nodes.Add("") 'TreeView1.Nodes.Add(oNode) Catch ex As Exception MsgBox("Cannot create initial node:" & ex.ToString) End End Try End If End Sub Private Sub TreeView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragEnter e.Effect = DragDropEffects.Copy ' If the data is text, copy the data tao the RichTextBox control. If e.Data.GetDataPresent(DataFormats.Text) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub Private Sub TreeView1_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles TreeView1.ItemDrag DoDragDrop(e.Item, DragDropEffects.Copy) End Sub Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Wraith Posted January 14, 2005 Posted January 14, 2005 try FileDrop instead of expecting windows explorer to send you tree nodes. Quote
georgepatotk Posted January 14, 2005 Posted January 14, 2005 this happened to me before as well. Actually there is a workaround availlable in MSDN. But I forgot where already.. Anyway, I had found out a c-sharp version of the workaround from Google. Feel free to have a look on here Quote George C.K. Low
georgepatotk Posted January 14, 2005 Posted January 14, 2005 ooppsss..... I thought you want ListView.. after re-read, only I found out you want treeview. sorry... Quote George C.K. Low
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.