Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
AM drawing multiple rectangles in my windows form and is saved to a rectangle list at run time.how do i move these rectangles with mouse and then save it to the rectangle list at run time so that the user can place these rectangles as they wish

What I have tried:

i tried to locate the points where i click belongs to any of the rectangles in the rectangle list but it didnt worked
Posted
Updated 14-Dec-16 21:51pm

"It didn't worked" is not pretty informative. Please elaborate.
Anyway, I suppose you are missing a conversion from Screen to Client coordinates (or the opposite). Have a loook at Mouse Events in Windows Forms[^] and at Control.PointToClient Method (Point) (System.Windows.Forms)[^] (for sample code).
 
Share this answer
 
to complete the Solution from CPallini a Little bit :

If you do a MouseDown on your Form you have to look it the actual MousePosition is at a coordinate-range of one of your rectangles.
If Yes you should memorize the actual MousePosition relative to the Rectangle-Postion.
If you now move your Mouse while it is pressed you could change the Rectangle-Postion according to this Movement.
But all this is not done automaticly - you have to code everything.

To be more specific you should improve your question with lots of more Info ... sorry ... :(
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900