I'm trying to implement datagridview's virtual mode but when i set RowCount to some number (to show the scrollbar) the grid wants to have all rows at once, not only the displayed.
DataGridView grid = new ...;
grid.VirtualMode = true;
grid.CellValueNeeded += OnCellValueNeeded;
grid.RowCount = dataprovider.GetFullCount();
How can i tell the grid to only request the rows displayed?
This is just a guess, but do you have the AutoSizeRowsMode or AutoSizeColumnsMode values set to AllCells or are any of the columns set to that either? Try setting the resize mode to None or just DisplayedCells and see if there is still a problem.
Not sure if this is the same problem as I was having, but I did get very poor performance when regularly drastically changing the RowCount on a VirtualMode DataGridView.
What I noticed was that the scroll bar was changing "slowly"; i.e. it looked like it was individually removing my virtual rows (!).
Anyway, doing a grid.Rows.Clear()
before each call to grid.RowCount = n
drastically improved performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With