Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Can anyone direct me to a tutorial on dragging shapes (rectangles, lines, etc.) around a form.

 

I have figured how to put a shape on a form, but I cannot seem to figure out how to manipulate at runtime by using mouse movements.

Go Beavs!!!
Posted

This is a difficult question to answer without knowing how you have put the shape on the form. As far as I'm aware the shape control that was available in VB wasn't included in the .Net Framework. This leads me to believe you must be drawing them with GDI+ (the Graphics object).

 

Without making more assumptions (too assume is to make an *** out of u and me) I can't really help much. But assuming everything I've said so far is correct then to move a shape around you would need todo the following.

 

- Store the shapes region publicly.

- In the mouse down events check if the cursor is in a region (by looping through each region).

- In the mouse move events if the mouse button is down and in a shape, move that shape relative to the cursor position.

- In the mouse up event release control of that shape.

 

If my assumptions were correct I can provide a more detailed answer, but it seemed pointless here as I'm not entirely convinced I'm thinking along the right lines.

Anybody looking for a graduate programmer (Midlands, England)?
Posted
Depending on why you are doing this it may be worth making a shape class and then inheriting it to make Square, Circle, or whatever classes.
Anybody looking for a graduate programmer (Midlands, England)?

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