I create an usercontrol with graphicspath. When i assign a click event in my main winform class, it doesn't fire when the usercontrol is clicked upon. I thought this had something to do with the region of the usercontrol so i created a new region with the graphicspath of my shape. I don't see any other reason why its not firing. What am i missing?

Assign event

public abstract class BaseShape : UserControl
{
    protected void DrawFill(PaintEventArgs e)
    {
        GraphicsPath path = CreatePath();
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
        using (SolidBrush brush = new SolidBrush(Fill.Color))
        {
            e.Graphics.FillPath(brush, path);
        }
        this.Region = new Region(path);
    }
}

public partial class Circle : BaseShape
{
    protected override GraphicsPath CreatePath()
    {
        GraphicsPath path = new GraphicsPath();
        path.StartFigure();
        path.AddEllipse(Contour.Weight, Contour.Weight, this.Width - 2 * Contour.Weight, this.Height - 2 * Contour.Weight);
        this.Region = new Region(path);
        return path;
    }
}

public partial class Main : Form
{
    private void Circle1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("tnjek");
    }
}

0 Answers