c# - 单击事件未从使用 graphicsPath 绘制的用户控件触发
问题描述
我用图形路径创建了一个用户控件。当我在我的主 winform 类中分配一个单击事件时,单击用户控件时它不会触发。我认为这与用户控件的区域有关,所以我用我的形状的图形路径创建了一个新区域。我看不出它不开火的任何其他原因。我错过了什么?
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");
}
}
解决方案
推荐阅读
- python-3.x - 如何在python列表中访问字典中的数据
- angular - minDate 在 bsDatepicker 中引发错误
- mysql - MySQL information_schema.tables UPDATE_TIME refresh on specific column change with ANALYZE TABLE
- firebase - Azure AD SSO for independent App Registrations
- r - system2("bash", "ls") -> 无法执行二进制文件
- reactjs - 解析错误:意外的令牌,预期的“,” - 与 Typescript 反应
- javascript - React state update issue
- arrays - 詹金斯管道将字符串推送到数组
- python - Nested dask delayed or futures
- sap-erp - How to extend "Create with reference" dialog in VA01/02