DataGridView的滚动事件(ScrollEventType.EndScroll)事件、DataGridView、EndScroll、ScrollEventType

2023-09-04 00:59:26 作者:追梦寻缘

在移交的 DataGridView.Scroll 事件,您可以检查它是否是滚动的结束(用鼠标拖动滚动条的时候,这是presumably当松开鼠标按钮)。

的问题是,这似乎从未发生。 e.Type 从不 ScrollEventType.EndScroll

有什么不好呢?我怎么只能做一些滚动完成时?

 私人无效dataGridView_Scroll(对象发件人,ScrollEventArgs E)
    {
        如果(e.Type == ScrollEventType.EndScroll)
        {
            // ...
        }
    }
 

解决方案

嗯,看来这个事件只是窃听。

连办7季, 奇葩说 靠什么继续讲故事

您可以在该DGV的私人滚动条的对象锁定(通过反射),并处理它们的事件,其中 ScrollEventType.EndScroll 出现预期。

请参阅此这个链接,如何做到这一点。

When handing the DataGridView.Scroll event, you can check whether it was the end of the scroll (when dragging the scroll bar with the mouse, this is presumably when the mouse button is released).

The problem is that this never seems to happen. e.Type is never ScrollEventType.EndScroll

What's wrong with this? How can I do something only when scrolling finishes?

    private void dataGridView_Scroll(object sender, ScrollEventArgs e)
    {
        if (e.Type == ScrollEventType.EndScroll)
        {
            // ...      
        }
    }

解决方案

Well, it seems that this event is just bugged.

You can latch on the the DGV's private scroll bar objects (via reflection) and handle their events, where ScrollEventType.EndScroll appears as expected.

See this this link for how to do it.

 
精彩推荐