DataGridView Scroll event (and ScrollEventType.EndScroll)

大兔子大兔子 提交于 2019-12-30 20:12:10

问题


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)
        {
            // ...      
        }
    }

回答1:


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.



来源:https://stackoverflow.com/questions/785200/datagridview-scroll-event-and-scrolleventtype-endscroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!