Manually adding a ToolStripStatusLabel Issues?

My program requires that at a certain point I manually add a ToolStripStatusLabel to my StatusStrip bar. I got it working to a point but I'm not sure it's the correct or accepted way to do so. When the program runs thru the code for the first time, even though the form in question has a StatusStrip along with a ToolStripStatuslabel already added, for some reason it appears as if it doesn't.

So, I execute the following code:

    If gSBR.Items.Count = 0 Then
        gSBR.Items(0).TextAlign = ContentAlignment.MiddleCenter
        gSBR.Items(0).Spring = True
    End If
    gSBR.Items(0).Text = "ESC - Close Form"


This code works but I'm not sure why I can't run this code:

    If gSBR.Items.Count = 0 Then
    End If  

It doesn't like the latter code.

Anyway, in the first set of code, I'm also trying to set the "Spring" property to True. Problem is, the Spring property doesn't show up in intellisense. How can I set this manually?
Who is Participating?
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
In your second piece of code, you need to pass an instantiated object to the Add method. The name of the class is not sufficient:

gSBR.Items.Add(New ToolStripStatusLabel)
BlakeMcKennaAuthor Commented:
Perfect James...worked like a charm!

BlakeMcKennaAuthor Commented:

I closed this out a little too soon. Your answer worked but was only part of the solution. I'm trying to reference the "Spring" property of the ToolStripStatusLabel and can't do it. Take a look at the last paragraph in my original post.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.