Fonzy Posted December 14, 2004 Posted December 14, 2004 Hi, Can anyone give an example or point me in the direction on how I can create an app which has a main picturebox, then on a button press it creates an image inside the picture box which can then be moved. Also when the mouse hovers over the image inside the picturebox it brings up a tooltip. Oh and the ability to move the images after they are in place. Thanks. Quote
Leaders Iceplug Posted December 15, 2004 Leaders Posted December 15, 2004 Sounds like you would add pictures to the inside of a picturebox by doing something like: PictureBix PBx = new PictureBox 'set properties. MainPB.Controls.Add(PBx) Then, you would use the Dragging events of the picturebox so that you can drag the picture around inside of the picturebox, DragEnter, DragOver, DragLeave, and DragDrop. .DoDragDrop starts the DragDrop process. I'm sure you know how to use a tooltip, but you can get one from the toolbox and experiment with it. :) They're pretty easy to use if you haven't used them yet. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Fonzy Posted December 15, 2004 Author Posted December 15, 2004 I've just started out in c# so am still learning its querks. I used to use java so its not all that different. Thanks to your advice ive put another picturebox in a main picturebox. My idea is to have a button which creates several pictureboxs inside a main picturebox and stores them in a collection object, if there is such a thing. The next thing is how do you write an event handler to allow dragging and dropping of pictureboxes that are created at runtime? And how does it identify which picturebox is being selected? The event handlers for objects seems hard coded, eg private void picturebox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { // do something } or does sender have which object is being dragged? Quote
Leaders Iceplug Posted December 16, 2004 Leaders Posted December 16, 2004 The first thing you do is start the DragDrop operation. From my drag drop sample article: Set your destination's .AllowDrop to True In your source's Mousedown, call its .DoDragDrop event. In the destination's .DragEnter event, check for .GetDataPresent and set the e.Effect. In the .DragDrop event, it is done! :) Tutorial is in VB.NET at XVBT, but here it is: http://www.xtremevbtalk.com/showthread.php?t=164308 Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
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.