2

我有 128 个小表单,全部排列在一个更大的 FlowLayoutPanel 中。128 个表单中的每一个都有自己的 onPaint 覆盖:

    protected override void OnPaint(PaintEventArgs e)
    {
        foreach (CustomSquare cs in this.customSquares)
        {
            this.formGraphics.FillRectangle(cs.colorBrush, cs.boundingRectangle);
        }
    }

每个表都实现了 MouseHover:

    public void customView_MouseHover(object sender, EventArgs e)
    {
        Debug.Print("greetings from table " + this.getTableNumber());
    }

现在,当鼠标在表之间切换时,事件处理程序会重复且轻松地触发,如下所示:

greetings from table 3
greetings from table 0
greetings from table 3
greetings from table 0
greetings from table 1

但是很难让 EventHandler 在同一张桌子上反复触发小鼠标移动或者说同一张桌子尺寸内部的移动,如下所示:

greetings from table 0
greetings from table 0
greetings from table 0

该程序的主要功能要求我非常频繁且始终如一地知道用户鼠标所在的 128 种形式中的哪一种,并且使用 MouseHover 事件似乎是最好的方法,但我希望它更频繁地触发。

4

1 回答 1

1

@Hans Passant 有正确的答案。

从 MouseHover 更改为 MouseMove 让事件触发者的反应时间非常快。

于 2013-02-23T02:46:35.063 回答