Link to home
Start Free TrialLog in
Avatar of joekendall
joekendallFlag for United States of America

asked on

How To Retrieve Data From Drag/Drop Of An Office Object

I am using VB.NET 2008 to develop a windows form application. I would like to know how to capture an object such as a Report that is in Microsoft Access 2003 that is being dragged and dropped. When you drag and drop a Report from Microsoft Access to the Desktop, it creates a link. How do I capture the Report that is going to be dropped and put the link it will create into a ListView in my VB.NET form?

Thanks for your help in advance!

Joe
Avatar of AUmidh
AUmidh

Avatar of joekendall

ASKER

I appreciate the links, but I have seen the same thing in other places. They just don't work for what I am doing. Here is my code in the DragDrop event of the ListView. It works fine if I have already made a link on the desktop and drag it over the ListView. It doesn't work though if I try to drag from Access over the ListView. Any help along those lines is appreciated. I thought there might be a way in the .NET framework without using an API. If I need to use an API, that will be fine as long as someone has some code I can use as a reference.

Private Sub lvObjects_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lvObjects.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            Dim i As Integer
            ' Assign the files to an array.
            MyFiles = e.Data.GetData(DataFormats.FileDrop)

            ' Loop through the array and add the files to the list.
            For i = 0 To MyFiles.Length - 1
                lvResults.Items.Add(MyFiles(i))
            Next
        End If
    End Sub

Thanks!

Joe
ASKER CERTIFIED SOLUTION
Avatar of joekendall
joekendall
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial