Click here to Skip to main content
15,861,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to drag and drop image into a form
Posted

 
Share this answer
 
It's difficult to answer this accurately, but Drag and Drop is not difficult.
Assuming you want to drag an image from Explorer onto you form:
1) Set the Form AllowDrop property to true.
2) Handle the Form DragEnter event.
VB
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
    e.Effect = DragDropEffects.Copy
Else
    e.Effect = DragDropEffects.None
End If

3) Handle the Form DragDrop event.
VB
Dim files As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop, False), String())
For Each file As String In files
    Console.WriteLine(file)
Next
You can then check for images and use the file as you wish.
 
Share this answer
 

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