Solved

Drag and Drop using pictureboxes

Posted on 2006-07-18
2
234 Views
Last Modified: 2010-04-23
Hi, everyone!!
I have a problem, i am doing an aplicattion in vb.net and i need to drag and drop one or more images over another images. i'm doing these using a picturebox with one of the images and another picture box with the other image. but i don't know how to do the drag and drop.
Can everybody help me???
Thank you
0
Comment
Question by:MartinCordoba
2 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 500 total points
ID: 17135150
Your first step would be to set the receiving picture boxes    "AllowDrop" property to true.

Then in your source picture box you need to add code to the Mouse Down Event to start the drag like this

Public Sub PictureBox1_MouseDown(sender as Object, e as System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
  Me.DoDragDrop(PictureBox1.Image,DragDropEffects.Copy)
End Sub

In your Receiving Picture Boxes you want to code the DragEnter and DragDrop Events Like This.

Public Sub PictureBox2_DragEnter(sender as Object, e as System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragEnter
  If e.Data.GetDataPresent(GetType(Image)) Then
    e.Effect = DragDropEffects.Copy
  Else
   e.Effect = DragDropEffects.None
  End If
End Sub

Public Sub PictureBox2_DragDrop(sender as Object, e as System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragDrop
  PictureBox2.Image = DirectCast(e.Data.GetData(GetType(Image)),Image)
End Sub

This is a simple scaled down version.   Hope this helps get you started.
0
 
LVL 9

Expert Comment

by:Naveen Swamy
ID: 17136408
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now