1
創建具有設計自定義用戶控件鼠標事件C#
我創建該設計的鼠標點擊事件作爲
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
e.Control.Click += new EventHandler(Control_Click);
}
protected override void OnControlRemoved(ControlEventArgs e)
{
e.Control.Click -= new EventHandler(Control_Click);
base.OnControlRemoved(e);
}
void Control_Click(object sender, EventArgs e)
{
this.OnClick(e);
}
鼠標事件是一個自定義的用戶事件只有當我點擊不包含PictureBoxes區域和標籤區域的區域時才工作。
我的意思是當我點擊用戶控件的圖片框區域或標籤區域時,鼠標點擊不起作用。在其他方面,鼠標點擊正在工作。
爲什麼?