1

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");
    }
}
  • So the handler is [hooked up?](https://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=1|0.3901#33276161)? Really?? – TaW May 18 '19 at 15:08
  • I fixed it by using the OnPaint method instead of my own method – Maxime Callebaut May 19 '19 at 13:05

0 Answers0