开发者

How can you determine when the user scrolls to the bottom of a DataGridView?

开发者 https://www.devze.com 2022-12-24 05:33 出处:网络
I am writing a C# Windows Forms Application in Visual Studio 2008. I have a DataGridView with a lot of data in it. I would like to initially only populate 10,000 rows and add more only when the user s

I am writing a C# Windows Forms Application in Visual Studio 2008. I have a DataGridView with a lot of data in it. I would like to initially only populate 10,000 rows and add more only when the user scrolls to the bottom. I am handling the DataGridView's Scroll event, but it never seems to raise with the ScrollEventArgs.Type property set to Last, which is the condition I think I need to catch to add more rows. I have read about people having bad experiences with the DataGridV开发者_如何转开发iew.Scroll event (e.g. DataGridView Scroll event (and ScrollEventType.EndScroll)), but the solution provided (How can I receive the "scroll box" type scroll events from a DataGridView?) only adds the ScrollEventArgs.Type property to come back as EndScroll, not Last like I need. Does anybody know how to get the event to raise properly, or another way to accomplish this task?


I would use the DataGridView's virtual mode (Microsoft's virtual mode walkthrough), which is designed for handling very large data sets. In virtual mode, you can catch the CellValueNeeded event. When the DataGridViewCellValueEventArgs.RowIndex is 10,000, you can add more rows to the table.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号