updating a lables text

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

I am looping through a number of files and I want to display the current
file name that is being processed to the form in a lable.

this.lblProcessing.Text = "Processing file: " +
this.lBxFiles.SelectedItems[ i ].ToString();

My broblem is that nothing is being display. I can do a

Console.WriteLine( this.lblProcessing.Text );

and it writes the correct file name.

Why is

this.lblProcessing.Text = "Processing file: " +
this.lBxFiles.SelectedItems[ i ].ToString();

not updating?

Is there a better way to do this?

Thanks,

Jerry
 
If you are using this code inside a tight loop, then that may be why
the lable is not refreshing. One thing you can try is to add an
Application.DoEvents call within your loop.

===============
Clay Burch
Syncfusion, Inc.
 
Jerry said:
I am looping through a number of files and I want to display the current
file name that is being processed to the form in a lable.

this.lblProcessing.Text = "Processing file: " +
this.lBxFiles.SelectedItems[ i ].ToString();

My broblem is that nothing is being display. I can do a

Console.WriteLine( this.lblProcessing.Text );

and it writes the correct file name.

Why is

this.lblProcessing.Text = "Processing file: " +
this.lBxFiles.SelectedItems[ i ].ToString();

not updating?

Is there a better way to do this?

Thanks,

Jerry

Because the thread that would do the update is busy looping through
files, so it's not receiving any messages.

You can call DoEvents to handle the messages in the queue.
 
Back
Top