DataGridView Scroll事件(和ScrollEventType.EndScroll) [英] DataGridView Scroll event (and ScrollEventType.EndScroll)

查看:115
本文介绍了DataGridView Scroll事件(和ScrollEventType.EndScroll)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当递交 DataGridView.Scroll 事件时,您可以检查是否是滚动的结尾(当用鼠标拖动滚动条时,这可能是当鼠标按钮被释放)



问题在于,这似乎并不会发生。 e.Type 永远不会 ScrollEventType.EndScroll



什么是错了这个?只有当滚动完成时,我该怎么办?

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

解决方案

嗯,似乎这个事件只是被发现。



您可以锁定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.

这篇关于DataGridView Scroll事件(和ScrollEventType.EndScroll)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆