Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drag and Drop using pictureboxes

Posted on 2006-07-18
2
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 2000 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

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

661 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