Drag and Drop From ListView to ListBox

I am using TreeView to display files in ListView  which works fine. I am trying to drag a file from the ListView to a ListBox to do things with the file but I cannot make it work. I do have Allow Drop set to True in the ListBox. Below is the code I have so far.

For the ListView
Private Sub lstDirectoryInfo_ItemDrag(sender As Object, e As ItemDragEventArgs) Handles lstDirectoryInfo.ItemDrag
        Dim lvItem As ListViewItem
        lvItem = CType(e.Item, ListViewItem)
        Dim importantData As String
        importantData = lvItem.Text
        Dim drp As DragDropEffects
        drp = lstDirectoryInfo.DoDragDrop(e.Item, DragDropEffects.Copy)
        MessageBox.Show(drp.ToString())
    End Sub

For The ListBox
Private Sub lstSFTP_DragDrop(sender As Object, e As DragEventArgs) Handles lstSFTP.DragDrop
        Dim str As String = CStr(e.Data.GetData(DataFormats.StringFormat))
        lstSFTP.Items.Add(str)
    End Sub
    Private Sub lstSFTP_DragEnter(sender As Object, e As DragEventArgs) Handles lstSFTP.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub

What I want to accomplish is have the filename in the ListBox.

Thank You
dthillsrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ktaczalaCommented:
looks like you assign drp to the dodragdrop function but you never enable the dodragdrop function for the listview
drp = lstDirectoryInfo.DoDragDrop(e.Item, DragDropEffects.Copy)
try this:
lstDirectoryInfo.DoDragDrop(e.Item, DragDropEffects.Copy)
0
dthillsrAuthor Commented:
That did not help. I need to mention also that when I click on an item in the listbox I get a circle with a line through it for the cursor I have enclosed a document with a print screen of that.
Drag-Error.docx
0
CodeCruiserCommented:
I think the issue is in your dragenter event. You are only allowing a drop if the item being dragged is a file which it isn't.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

dthillsrAuthor Commented:
Would you know how I would adjust the code?
0
dthillsrAuthor Commented:
I have figured this out and no longer need assistance.
0
dthillsrAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for dthillsr's comment #a40687755

for the following reason:

I did more research on listview in order to correct the problem.
0
David Johnson, CD, MVPOwnerCommented:
and your solution was?  please do not enclose graphics in a word document in the future
0
dthillsrAuthor Commented:
This is the code I used to copy a file from my listview to listbox.

Dim lvi As ListViewItem = lstDirectoryInfo.SelectedItems(0)
lstSFTP.Items.Add(lvi.Text)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.