471,596 Members | 849 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,596 software developers and data experts.

Form controls don't update in sync

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?
Jan 18 '06 #1
2 2341
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.

"Dick Swager" wrote:
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?

Jan 18 '06 #2
Thanks Mark, the Refresh() works.
"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
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.

"Dick Swager" wrote:
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?

Jan 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Neo Geshel | last post: by
8 posts views Thread by Vivek | last post: by
6 posts views Thread by Peter Zolja | last post: by
4 posts views Thread by Simon Tamman {Uchiha Jax} | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.