Using VirtualMode on a DataGridView when the number of rows/columns isn't known
- by Nathan Baulch
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?