Picture Box drag drop

jjrai

New member
Joined
Jul 11, 2003
Messages
2
I have an image in a picture box. I want a user to be able to drag from a tree view onto my picture. When he does this, the image that I have assigned to the treeNode will be displayed at the coodinates of the mouse. Can anyone tell me how I can get access to the bitmap that is associated with the node, and then how to display it in my Picture box, on top of the image that I have there already. I also want to be able to move the different images that I put there. I have tried to do this, but the closest I get is to have the drop look like its working over the picture box, but nothing drops. Here is the code that I have for the OnDrop.

private void OnPictureDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
Bitmap b = new Bitmap(@"c:\\bitmap1.bmp");
Graphics g = pictureBox1.CreateGraphics();
g.DrawImage(b,e.X,e.Y);
g.Dispose();
}

Cheers,

JJ:)
 
Thanks

Sorry for the long wait, I got the program running, and your answer was helpful.

Thanks
 
It should have been either
C#:
 Bitmap b = new Bitmap(@"c:\bitmap1.bmp");
or
C#:
 Bitmap b = new Bitmap("c:\\bitmap1.bmp");

in C# (like other C based languages \ denotes an escape sequence i.e. \t is tab, \n is new line etc) if you really mean to use a tab then \\ is treated as a single tab. If you precede a string with @ then it doesnt escape any \ characters
 
Back
Top