0

FlowLayoutPanels在表格上有两个:PanelAPanelB。每个都将在运行时填充多个控件,以便面板滚动(即为AutoScroll真)。

这是问题所在:面板填充的每个控件都包含一个ComboBox. 因此,MouseWheel事件由组合框而不是面板使用。我希望MouseWheel面板使用事件。

如果子控件上没有可滚动控件,则MouseWheel事件会跳过子控件(它不处理它)并点击处理它的面板。如何设置我的子控件的组合框以忽略该MouseWheel事件?我可以告诉它重新引发事件吗?

每当其中一个子控件勾选“MouseEnter”事件时,我都尝试将焦点应用于父级;这解决了滚动问题,但也使子控件完全不可编辑。

我从挖掘中发现的其他东西涉及直接摆弄 Windows API,但我发现很难相信这样的东西是必需的。

4

1 回答 1

1

我测试了以下代码,它似乎可以解决您的问题。基本上,当您单击“FlowLayoutPanel”或鼠标进入它时,您需要将其聚焦:

private void newCheckListQuestionPanel_Click(object sender, EventArgs e)
{
   newCheckListQuestionPanel.Focus(); //allows the mouse wheel to work after the panel is clicked
}
private void newCheckListQuestionPanel_MouseEnter(object sender, EventArgs e)
{
   newCheckListQuestionPanel.Focus(); //allows the mouse wheel to work after the panel has had the mouse move over it
}
于 2012-10-31T16:04:57.663 回答