Link to home
Start Free TrialLog in
Avatar of garyhoffmann
garyhoffmann

asked on

Drawing a Bounding Box rectangle in vb.net 2005

Hello,

I never thought I'd actually be writing on how to do this, but I am having nothing but trouble getting this to work.

I have a picture on the screen.  I want to give the user the ability to crop the picture, so I have a crop button on the toolbar.  When cropping starts, I want the user to be able to click and drag around the area that they want to keep within the picture.  I would like to draw a rectangle AS they move the mouse.

What I'm running into is I can do the draw rectangle, but as the mouse moves, another rectangle is created and another, etc. so I end up with a series of rectangles rather than one when I'm all done.

In vb6 world, I used a "shape" to accomplish this and just kept moving the bottom right point of the shape.  I just don't know how to do this in vb.net 2005

Thanks so much
Gary H.
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 garyhoffmann
garyhoffmann

ASKER

Idle Mind - this is great.  Thank you.  But... (and there's always a but....)

What if the user realizes they started in the wrong place and wants to start over?  How do I remove the rectangle that's been drawn?

Thank you.
Gary.
Idle Mind,

Never mind - I found my own answer based on your code.  Thanks again.

Gary
To clear the PB just issue a Refresh() and any existing bounding box will be cleared:

    PictureBox1.Refresh()