WinForms:当鼠标进入控件时如何使MouseEnter触发?

标签 winforms

我有一个Panel,其中包含任意数量的子控件:

enter image description here

如果鼠标进入Panel中的子控件之一:

enter image description here

然后 PanelMouseEnter 事件不会被触发。

Note: A related problem is that if the mouse moves from the the panel to one of the child controls, then the Panel's MouseLeave event is fired:

enter image description here

Even though the mouse did not leave the panel.

如果鼠标进入面板上的子控件“任何”,如何触发 PanelMouseEnter 事件?

最佳答案

类似于:

foreach (Control ctrl in panel1.Controls)
            ctrl.MouseEnter += panel1_MouseEnter;

关于WinForms:当鼠标进入控件时如何使MouseEnter触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8172535/

相关文章:

c# - 从字典填充控制值?

c# - 为什么win32异常没有被c#异常处理机制捕获

c# - 使用任务更新 GUI

c# - TextBox的OnPaint方法没有被调用?

c# - CancellationTokenSource 需要建议

c# - 如何在显示窗体时将默认焦点设置在 C# Winform ToolStripMenuItem 上?

c# - 将allowdrop设置为true会导致.net应用程序中的内存泄漏

c# - winforms中的验证文本框

C# 应用程序需要在 Citrix 环境中引用远程工作站

c# - 条件委托(delegate)问题