Badr
Badr

Reputation: 10648

how to draw lines and shapes on picture box on mouse move event in c#?

i am trying to draw a rectangle when i press mouse left button and drag. i want to show the size of rectangle change according to move of mouse. how is it possible. i tried to paint on picture box but the rectangle draw when i release the mouse button. i want to show it during drag?

it just like we click on our windows desktop and and darg the mouse we see a rectangle growing with mouse move i have to do this any other option?

Upvotes: 1

Views: 3045

Answers (3)

Bobby Flay
Bobby Flay

Reputation: 11

You can do this with Windows XP, just not Windows 7. If I am understanding your inquiry correctly, you have to hold down the "Start" button key on your keyboard while dragging. You have to let go of the key on the keyboard before letting go of your mouse. Otherwise, your art will be deleted. Pull up a window (i.e. Microsoft Word) and shrink the window. You can drag this around, and use it as an "eraser" if you will. I hope that this is what you are looking for.

Upvotes: 1

Asha
Asha

Reputation: 4311

if you want to use the paint method then you should handle all repaint event and other complexities of GDI+ . but the easy way is to create a panel with borders on mouse click and when the mouse is moving change panel properties and with mouse release you will have the panel and your rectangle and no need to worry about repaint and ... .

Upvotes: 0

Related Questions