Link to home
Start Free TrialLog in
Avatar of DJ_Back-Q
DJ_Back-Q

asked on

Create draggable retangle shapes in a Picturebox.

I want the users of a Windows Forms application to be able to drag simple rectangle shapes arround in a picturebox and then save this picture as a file.

I have no problem with saving the file. The problem I have is creating draggable rectangle shapes. These rectagle shapes will be created by the application. The only thing the user needs to do, is drag them arround and place them in the correct position.

For those who thinks this is kind of wierd: This is for an application used by sales representative from a sign company. We want the sales representative to be able to give us a sketch of the layout of the signs on the post.

Thanks everyone.
Avatar of jrandallsexton
jrandallsexton

One thing you could do would be to create your own class and inherit from Panel.

Public Class Sign: Inherits Panel

   'Override the Paint method and draw whatever shapes you need inside the bounds of the panel

End

This way you can use standard drag and drop functionality exposed from the base class.

However, as far as dragging it around the picture box - I'm not sure.

If it is going to be just Rectangular shapes then what you can do is use a Label control instead of Drawing a Rectangle

What I am suggesting is When user draws a Rectangle inside the Picture box Dynamically add a Lable control with visible border and no text so that it looks like a rectangle. Now when he needs to  moves this rectangle (i.e. the Label control) you can use the Drag Drop events to actually move the Lable.

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DJ_Back-Q

ASKER

Thanks everyone,

I will have to go with Idle_Mind, that guy wrote the whole damn code for god sakes!!! It's exactly what I wanted.

Thanks alot Idle_Mind, you know what you do.
Vey cool, Idle_Mind
Very nice, Idle_Mind.