OnLoad

  • Thread starter Thread starter Burns
  • Start date Start date
B

Burns

Hi,

I've built a form with a progress bar on in C#, I want
some code to run once the form is opened and update the
progress bar as it does. The only event I can find to
initiate my code is in the form's Form_Load event, but
when this code is executed, the form has not yet been
displayed.

I need to run some code once the form has been displayed,
how do I do this?

Burns
 
Burns said:
I've built a form with a progress bar on in C#, I want
some code to run once the form is opened and update
the progress bar as it does.

If you can split the task into discrete chunks, a Timer control would be
appropriate.

P.
 
Hi

you can not use the "Load" event of the form here, since a form gets loaded only after executing all the code in the "Load" event. The solution to your problem is to attach a new event handler to the "Paint" event of the progress bar control. And use the graphics object of the "PaintEventArgs" to redraw the progress bar. You can fire the "Paint" event whenever the status on the form has changed to reflect that on the progress bar.

In case you are not using the progress bar control, you can use the "Paint" event of the form.
 
Sorry.. a little out of touch after a long vacation.

It's VisibleChanged event!

-vJ
 
Back
Top