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,
I donno why am i getting the other, is there any other code to do this.
Thanks
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)
{
}
}
}
Thanks
Comment