Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't update label in status strip 2

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,485
9
38
Scotland
www.ml-consult.co.uk
Hi All,

I am using C# Express. I am fairly new to C# and .NET, and have just finished a small one-form application.

My problem is that I can't get the label in my status strip to work.

I placed a status strip control on the form, and used its built-in Add button to add a label and a progresss bar. The controls are named ssStatus, ssLabel and ssProgress respectively.

In my program's main loop, I call a routine to update the pogress display:

Code:
// Update the progress bar and label
ssStatus.Visible = true;
ssLabel.Text = "Processing " + nCount.ToString();
ssProgress.Minimum = 0;
ssProgress.Maximum = tnMax;
ssProgress.Value = tnCount;

I can see the progress bar being correctly updated, but I don't see any text in the label. I've used the debugger to check that the label's Visible is True, and that it's wide enough to hold my text. And if I set the label's text at design time, it shows up correctly.

Can anyone see what I am doing wrong?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Code:
// Update the progress bar and label
ssStatus.Visible = true;
ssLabel.Text = "Processing " + nCount.ToString();
ssProgress.Minimum = 0;
ssProgress.Maximum = tnMax;
ssProgress.Value = tnCount;

Application.DoEvents();

Do what sajidi99 suggested but do it after you make all GUI changes.

 
Make sure that the Autosize property is set to true.. otherwise, if you have 0 length for the label at design time, and the label size is too small, during runtime, it will not resize the label to fit the text, hence the problem not seeing any text in your label.

Cheers,

G.



Oxigen - Next generation business solutions
-----------------------------
Components/Tools/Forums/Software/Web Services
 
Application.DoEvents(); did it. I should have guessed it was something like that (I was thrown by the fact the progress bar was updated even though the label wasn't).

Thanks Ch Saj and JurkMonkey.

Gorkem: Thanks also for your suggestion re Autosize. I did try that, but in fact it made no difference in this case because I had already sized the label to hold the largest likely text.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top