I have the same problem, and I tried the solution to set the active flag like you, and I also tried the solution to set the RowCount to 0 (or grid.Rows.Clear ()) before setting up a new RowCount.
Both of these things have improved performance, but have not accelerated it as much as I want, since I dynamically filter the grid in real time based on input from the search box.
I found two other solutions:
1) Use pagination so that you do not need to set the RowCount so high as to start with. I think this is a great solution if you are already using pagination (in which case you will not be here), but too cumbersome if you do not plan to implement it.
2) Place a call to install the RowCount in your own thread. This is the one I'm going to do. Honestly, Iβm not sure how safe it is if you try to edit cells while the stream is still ending, but I think I will find out soon.
EDIT:
OK, so I tried streaming, hoping it would be a trick since I read elsewhere that it really helped the other guy. This seems to be a good solution if you are going to change the value once in a while, but it still hangs if you do it several times in a row (which I am). I think this is due to the fact that you should use Invoke (), and the second time you are still waiting for the completion of the first. I canβt say that I fully understand what a deal is, but I decided to just live with empty rows, because this SOOO is much faster and less complicated when I just leave them there.
source share