Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 01-05-2009
Member
 
Join Date: Apr 2009
Posts: 68
Drag & Drop PictureBox

Hello,

I search lot on the forum and on the blogs regarding drag and drop of images, but not really what I'm looking ... Yet it seems so simple,but not getting any clue where to start with!

I would like to make Drag and drop images in Two stpes.

If anyone click on an image and move the mouse, and if I release the button it stays on its new location.

When I put on my image1 and image2 I release the button, then my image1 replaces image2.

I come to the above two solutions as I find it very unique and very new,and I search lot for these two ideas and I know for the some extend this is possible.

Your suggestions would be appreciated.
Thank you
Reply With Quote
  #2  
Old 01-05-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: Drag & Drop PictureBox

I will provide you the programming stuff which will help you to understand how the drag and drop of Images performs for PictureBox.

Code:
 public partial class Form1: Form 
  ( 
      public Form1 () 
      ( 
          InitializeComponent (); //here we will initialize the content of form
      ) 

      private void pictureBox1_MouseMove (object sender, MouseEventArgs e) 
      ( 
          if (Button == e. MouseButton. Left) //clicking the mouse left button event
              pictureBox1. DoDragDrop (pictureBox1. Image, DragDropEffects. All);   
      ) 

      private void Form1_Load (object sender, EventArgs e) 
      ( 
          pictureBox2. AllowDrop = true; 
      ) 

      private void pictureBox2_DragEnter (object sender, DragEventArgs e) 
      ( 
          if (e. Data. GetDataPresent (DataFormats. Bitmap)) 
              e. Effect = DragDropEffects. Copy; 
          else 
              e. Effect = DragDropEffects. None;  
      ) 

      private void pictureBox2_DragDrop (object sender, DragEventArgs e) 
      ( 
          if ((e. Data. GetDataPresent (DataFormats. Bitmap))) 
              this. pictureBox2. Picture = (Bitmap) (e. Data. GetData (DataFormats. Bitmap)); 
      ) 
  )
This is an excellent example of what have been asked, and the above code is pretty well described and it is continuous flow.
Reply With Quote
  #3  
Old 01-05-2009
Member
 
Join Date: Apr 2009
Posts: 68
Re: Drag & Drop PictureBox

Thank for your reply,

I will test your and let you know, now I also search one program for the same on the internet. so soon it will get completed i will work on your code.

I am rather developing this code for the purpose of working on the gaming stuff, as I saw your program on the head i suppose you have not mentioned the case two and is precisely that:

pictureBox1 can be source and destination pictureBox2
or
pictureBox2 can be source and destination pictureBox1

If it's really not possible, I am an alternative, if a PictureBox enter into any contact with another, I move the other.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Drag & Drop PictureBox"
Thread Thread Starter Forum Replies Last Post
Opera 11 cannot drag and drop links Calandar Technology & Internet 5 16-01-2011 08:08 AM
Drag an drop on htc hd2 home screen Sindu Portable Devices 5 09-06-2010 06:35 AM
Drag and drop transcoding in windows 7 Susquehannock Windows Software 6 04-06-2010 12:30 AM
Example Method for Drag and Drop in ASP.NET GUSSIE Software Development 3 07-07-2009 12:54 PM
CMD drag and drop in Windows 7 Justvicks Operating Systems 2 20-03-2009 06:36 PM


All times are GMT +5.5. The time now is 05:54 AM.