Click inside graphic square WinForms GDI
Posted on 2007-08-05
I'm working with WINFORMS and 2005 C#;
How do I know when a click happens inside a graphics square?
Graphics gfx = this.panel1.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Yellow);
gfx.FillRectangle(sb, 120, 60, 40, 40);
Pen bPen = new Pen(Color.Black)
gfx.DrawRectangle(bPen, 120, 60, 40, 40);
Above code draws a black box filled with yellow. Thats good! How do I know when a user clicks INSIDE the yellow box? What technique can I use to capture the mouse click?