Changes to DataGridView on Form in Shown event don't appear

  • Thread starter Thread starter Dan Cooperstock
  • Start date Start date
D

Dan Cooperstock

I have a form with a DataGridView on it. It's not data bound - I custom
designed the columns, and create rows and fill in column values
programatically.

I'm in the Shown event handler for the form, and I am doing processing that
takes a bit of time, and updating the DataGridView as the processing
happens, to show progress. (The user doesn't initiate the processing - it
just happens as soon as the form is shown.)

However, only the title bar and the outline of the form displays at first.
I don't see any updating of the DataGridView until all of the processing
has finished, at which point I show a MessageBox to tell the user it
completed successfully. I even tried adding Thread.Sleep(0) calls after I
updated the DataGridView, in order to yield control so that the updating
could be seen, but that didn't change anything.

Any bright ideas? Thanks.
 
Never mind. I called Refresh() on the form after each change, and that did
it. Of course, if there is a better solution, do please let me know.
 
Back
Top