天天看點

Winform中userControl滑鼠事件不響應

問題描述:使用者控件存在遮擋問題,一般使用者控件會由許多基本控件聚合的,但預設事件是不穿透的,隻有滑鼠作用到userControl本體上才會起作用

解決方案:對于上層的遮擋的控件進行事件轉發

private void livingBeingsUnitView_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
        }

        private void tableLayoutPanel_main_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
        }