Reputation: 369
I create a custom user event which has a design as
I create a mouse click event for that design as
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);
}
The mouse event is working only when I click the area which is not includes PictureBoxes areas and label areas.
I mean when I click on the user control's pictureboxes area or label area, mouse click is not working. On the other areas, mouse click is working.
Why?
Upvotes: 3
Views: 2623
Reputation: 5294
Try this:
Add to your control an event like:
public new event MouseEventHandler MouseClick
{
add
{
base.MouseClick += value;
foreach (Control control in Controls)
{
control.MouseClick += value;
}
}
remove
{
base.MouseClick -= value;
foreach (Control control in Controls)
{
control.MouseClick -= value;
}
}
}
I think this solve your problem.
Upvotes: 2
Reputation: 75
https://msdn.microsoft.com/ru-ru/library/ms171545(v=vs.110).aspx
Only the foreground window can capture the mouse. When a background window attempts to capture the mouse, the window receives messages only for mouse events that occur when the mouse pointer is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground. When the mouse is captured, shortcut keys do not work.
Try to look for the using of transparent backColor.
Upvotes: 0