嗯,这是技术上是可行的。您必须自己重定向鼠标消息,这需要一点P/Invoke。将此代码粘贴到您的内部UserControl类中:
protected override void WndProc(ref Message m) {
// Re-post mouse messages to the parent window
if (m.Msg >= 0x200 && m.Msg <= 0x209 && !this.DesignMode && this.Parent != null) {
Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
// Fix mouse position to be relative from parent's client rectangle
pos = this.PointToScreen(pos);
pos = this.Parent.PointToClient(pos);
IntPtr lp = (IntPtr)(pos.X + pos.Y << 16);
PostMessage(this.Parent.Handle, m.Msg, m.WParam, lp);
return;
}
base.WndProc(ref m);
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr PostMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
这是最好避免顺便说一句。父控件可能只需订阅内部控件的鼠标事件。