Drag drop image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashwinigopi
    New Member
    • Jul 2008
    • 7

    Drag drop image

    Hi
    I am trying to drag and drop image to a picture box in the form. I using this code but doesnt seem to work. Here is the code,
    Code:
     private void Form1_DragEnter(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.Bitmap))
                {
                    e.Effect = DragDropEffects.Copy;
                }
                else
                {
                    e.Effect = DragDropEffects.Move;
                }
    
            }
    
            private void pictureBox1_DragDrop(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(DataFormats.Bitmap))
                {
                    pictureBox1.Image = (e.Data.GetData(DataFormats.Bitmap)); // why am i getting this error
                }                                                              // what other command can i use
                else
                {
                    MessageBox.Show("format not supported");
                }
    
            }
    
            private void pictureBox1_DragLeave(object sender, EventArgs e)
            {
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
        }
    }
    I donno why am i getting the other, is there any other code to do this.
    Thanks
    Last edited by Curtis Rutland; Aug 7 '08, 03:10 PM. Reason: Added Code Tags - Please use the # button
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    im not real experienced in the drawing area of visual basic but here are two links on how to drag and drop other pictures to your picture box,




    Comment

    Working...