MiSheps
asked on
Visual C# - How to Refresh datagrid, and other items when datagrid is populating.
Greetings Experts,
Ok, I have a datagrid that I populate with network information. But while the data is being gathered for the datagrid, the form seems hung, which of course it is not, it just isn't repainting. Then when the datagrid has everything it needs, bam! everything shows up, and looks great.
This includes a animation of sorts that I've created to show that the program is actually still working (processsing) which does nothing more then cycle through 8 images to show motion....
But when the datagrid is gathering info, nothing refreshes at all.
I have tried starting a "timer" prior to the datagrid call, where in the timer, it has a refresh of the specifc picturebox's that I want to refresh, (ie. picMyPic1.refresh();) but that didn't work to refresh the "animation" while the datagrid was working on gathering the info.
I also tried just doing a refresh(); on a timer, to just refresh the whole form, again, no dice.
I've also tried putting refresh events into the animation itself (which is on a timer that cycles through the 8 images), but again, no dice...
So, the Q is... how do I activly refresh the screen so that it doesn't look like my app is hung while my datagrid is searching and building it's data.
Thanks!
Ok, I have a datagrid that I populate with network information. But while the data is being gathered for the datagrid, the form seems hung, which of course it is not, it just isn't repainting. Then when the datagrid has everything it needs, bam! everything shows up, and looks great.
This includes a animation of sorts that I've created to show that the program is actually still working (processsing) which does nothing more then cycle through 8 images to show motion....
But when the datagrid is gathering info, nothing refreshes at all.
I have tried starting a "timer" prior to the datagrid call, where in the timer, it has a refresh of the specifc picturebox's that I want to refresh, (ie. picMyPic1.refresh();) but that didn't work to refresh the "animation" while the datagrid was working on gathering the info.
I also tried just doing a refresh(); on a timer, to just refresh the whole form, again, no dice.
I've also tried putting refresh events into the animation itself (which is on a timer that cycles through the 8 images), but again, no dice...
So, the Q is... how do I activly refresh the screen so that it doesn't look like my app is hung while my datagrid is searching and building it's data.
Thanks!
ASKER
I was guessing that I would have to start the animation in another thread, but was hoping it would be something easier. I tried the DoEvents(); but it didn't work.
Do you have an example of how I could start the animation in a second thread?
Thanks.
Do you have an example of how I could start the animation in a second thread?
Thanks.
Well, I don't have idea on how it will work on the same Form. Probably opening another Form with animation is good. If you open a small popup Form with the animation, then that can solved the problem. For this see the following link:
https://www.experts-exchange.com/questions/23582542/Controlling-a-second-form-on-a-separate-thread-in-C.html
https://www.experts-exchange.com/questions/23582542/Controlling-a-second-form-on-a-separate-thread-in-C.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
After the line where you fill the DataGrid, use:
Application.DoEvents();