Using VirtualMode on a DataGridView when the number of rows/columns isn't known

Posted by Nathan Baulch on Stack Overflow See other posts from Stack Overflow or by Nathan Baulch
Published on 2010-05-16T07:07:54Z Indexed on 2010/05/16 7:10 UTC
Read the original article Hit count: 258

Filed under:
|
|
|
|

I need to display an unknown length sequence of dictionaries with unknown keys efficiently in a data grid. This sequence is the result of a potentially slow LINQ query that could contain any number of results.

At first I thought that VirtualMode on DataGridView was what I was looking for but it appears that the number of rows and columns must be known upfront. I tried adding a single row and column then adding more as needed from the CellValueNeeded event but this doesn't work.

Is this even possible with VirtualMode? Or do I need to estimate how many rows are visible on the screen and manually build up the rows/columns? And if so, how do I ensure that a vertical scrollbar is present and react appropriately when a user uses it?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about winforms