jjrai Posted July 11, 2003 Posted July 11, 2003 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:) Quote
Hamburger1984 Posted July 11, 2003 Posted July 11, 2003 Wrote a little App... maybe this'll help you - at least you'll get an Idea how to do it... Andreaspicturedragdrop.zip Quote
Hamburger1984 Posted July 13, 2003 Posted July 13, 2003 ...and by the way thanks for the reply/feedback j/k :p Quote
jjrai Posted February 24, 2004 Author Posted February 24, 2004 Thanks Sorry for the long wait, I got the program running, and your answer was helpful. Thanks Quote
Hamburger1984 Posted February 24, 2004 Posted February 24, 2004 oh well that was quick ;) great to see that it reached the goal.. Quote
ThePentiumGuy Posted February 24, 2004 Posted February 24, 2004 Bitmap b = new Bitmap(@"c:\\bitmap1.bmp"); quick q, whats the @ do? thx Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Administrators PlausiblyDamp Posted February 24, 2004 Administrators Posted February 24, 2004 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ThePentiumGuy Posted February 24, 2004 Posted February 24, 2004 ah, thanks for the reply Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.