Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 it's 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:)

  • 7 months later...
  • Administrators
Posted

It should have been either

Bitmap b = new Bitmap(@"c:\bitmap1.bmp");

or

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 doesn't escape any \ characters

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...