简体   繁体   中英

Adding Event listener to drawn objects

At the moment I am drawing rectangles using Windows Forms.

g.DrawRectangle(new Pen(Color.Black),new Rectangle(new Point(10,10),new Size(50,50)));

But I would like to add Event Listener to this so that I can make them moveable and resizeable.

Can I do this using Windows Form DrawRectangle() or is there a different way?

You can use Panel 's instead.

If you want them movable and resizeable - use Form 's. (See this answer .)

(As for events for drawn objects like in your example - I don't know of a simple way to do that. But you can try calculating where the mouse clicked on the Form...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM