views:

39

answers:

0

I've made a Figure class that paints a square or circle etc based on constructor input. Each instance of Figure paints a figure to my Panel canvas. I have a record of each instance and am painting them using the Panel's paint event.

NOW, I would like to trace each of these instances by clicking on it's graphic (so I could maybe delete one or move it).

I tried to assign a MouseEvent to each Figure instance but it never fires when I click the graphic. (I also have a MouseEvent on the Canvas itself, maybe it overwrites the figure's Mouse event?)

figureArray[i].MouseClick += new MouseEventHandler(figure_click_function);

Is it even possible to have a MouseEvent fire by clicking on the graphic drawn by the class it was attached to? If not, help please!

[EDIT] Here's more of my source code:

private void canvas_click(object sender, MouseEventArgs e)
    {
     try
            {
                i++;
                figureArray[i] = new Figure(x, y, width, height, thickness, color, type);
                figureArray[i].MouseClick += new MouseEventHandler(figure_click_function);

[....]

and I've also got: private void figure_click_function(object sender, MouseEventArgs e) {//with a writeline}

It's a WinForm, and Figure class extends Control