Form controls don't update in sync

D

Dick Swager

I have a form with a progress bar and a label. The form launches a class
that raises an event to indicate the progress. The event arguments contains
integers to update the progress bar and a string to update the label. The
event handler modifies the two controls with values from the arguments.
But... the progress bar updates fine but the label does not. The label
control will update but not the event has been handled several times. I put
a message box inside the event handler to assure that both controls were
being processed, they both do update as I would expect.

I tried using a TextBox instead of a Label with no difference. I tried an
'invalidate' on the form, no difference. I compiled with VS 2003 and VS
2005, same behavior.

What am I missing here?
 
G

Guest

Is your main processing happening in the Main UI thread or a seperate thread?
If it is in the main UI thread then maybe the label is not getting chance to
update because the thread is busy processing. Try calling Label::Refresh()
to force an update of Application.DoEvents() to allow the paint related
messages to be processed.

Also a code sample showing the problem would be useful in possible.

Mark.
 
D

Dick Swager

Thanks Mark, the Refresh() works.


Mark R. Dawson said:
Is your main processing happening in the Main UI thread or a seperate
thread?
If it is in the main UI thread then maybe the label is not getting chance
to
update because the thread is busy processing. Try calling
Label::Refresh()
to force an update of Application.DoEvents() to allow the paint related
messages to be processed.

Also a code sample showing the problem would be useful in possible.

Mark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top