Results 1 to 3 of 3

Thread: Drag & Drop PictureBox

  1. #1
    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

  2. #2
    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.

  3. #3
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,631,865.26627 seconds with 17 queries