Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Leaders
Posted

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.

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

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?

  • Leaders
Posted

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

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

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...