On 2007-11-05 06:46:03 -0800, "Rinaldo"
<zw*************@hotmail.com.nospamsaid:
I have a label on my dialogbox who has to change text while running.
This is what I do:
lblBackup.Text = "Bezig met de backup naar " + F1.FTPserver;
but the text does'nt appear, only if I draw (call) a messagebox, then
the text appears. What can it be? I had made a total new one, but
did'nt help.
If I had to guess (and I do, because you didn't post nearly enough code
to illustrate what you're actually doing), I'd guess that you are in
some sort of processing loop in which you change the Text property of
the Label and that processing loop is in the main UI thread.
If that's the case, then until the processing loop has completed and
whatever UI method started the processing loop returns, nothing in your
UI will be able to redraw itself, including the Label that you've
changed.
If you have a lengthy processing to do and you have a need for the UI
to remain responsive (including redrawing when you update it), then you
need to put the processing into a different thread so that the UI can
update itself when necessary.
The BackgroundWorker class is ideal for simple examples of this sort of
situation. You can use it to run your processing, and from the
processing code use the Control.Invoke() method to execute code that
will update the UI. Then the UI changes will actually be visible to
the user while the processing goes on.
Pete