Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am using VB2010 Pro
I am using a borderless form.

I have the AllowDrop property set to "True"
Here is the code I am using. It's common code.

VB
Private Sub CreateIcon(ByVal bitmapName As String)
        Try
            Dim fi As New System.IO.FileInfo(bitmapName)
            Dim bmp As New Bitmap(fi.FullName)
            Dim sw As System.IO.StreamWriter = System.IO.File.CreateText(fi.FullName.Replace(fi.Extension, ".ico"))
            Icon.FromHandle(bmp.GetHicon).Save(sw.BaseStream)
            sw.Close()
        Catch ex As Exception
            System.Diagnostics.Debug.WriteLine(ex)
        End Try
    End Sub

    Private Sub frmAppPanel_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
        Dim arr As Array = DirectCast(e.Data.GetData(DataFormats.FileDrop), Array)
        For i As Integer = 0 To arr.Length - 1
            CreateIcon(Convert.ToString(arr.GetValue(i)))
        Next
    End Sub

    Private Sub frmAppPanel_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub


I am dragging Images from the Pictures folder onto the form
and I keep getting the ( NO SMOKING SIGN ) cursor when I goto
drop all the images wether it is 1 or 21.

I have used basically every piece of code I could find for the
drag and drop operation and none work.

My question is "Does anyone know how todo this?" If so, could
you point me in the right direction?.
Posted
Comments
Bert Mitton 22-Aug-11 13:52pm    
Could you see what the dataformat is? I'll bet it's not coming through as a FileDrop for some reason.

Where is the drag starting from? Is it starting from a Windows folder? Or is it starting from your program?

Did you read the 3rd line in the post?
 
Share this answer
 
Set your Forms AllowDrop to true, that should do the trick

OP >> Did you read the 3rd line in the post?
No I missed that. And in that case the code works on my end. So I suggest you double check that and then place a break point in frmAppPanel_DragEnter to see what's going wrong
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900