Access toolstrip items from code behind

I have a winforms application that has many forms.  I use a bindingnavigator and on that is a label (toolstriplabel).  I have a module which has a public function that I want to update the label from.  Since this is used by multiple forms I need someway of doing this..

What is the correct syntax for to do this?  An example would help greatly.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I'm writing my first .Net app at the moment, so apologies if this proves to be utter nonsense...

Could you create a string property in the BindingNavigator class that you could get/set as you need?

        /// <summary>
        /// Holds the selected LabelText for the BindingNavigator.
        /// </summary>
        private string labelText;
        public string LabelText
            get { return this.labelText; }
            set { this.labelText = value; }

Open in new window

Set the BindingNavigator's LabelText property from your function (once you have created an object reference to the BindingNavigator).  You could then refresh the text in your label by getting the BindingNavigator's LabelText property.

Hope this helps - if not, apologies!
K-9Author Commented:
I was able to resolve it with this..

Function ChangeToolStripLabel(ByVal Process As String)
        Dim currentForm As Form = Form.ActiveForm

        ' Loop through all the controls on the active form. 
        Dim i As Integer
        For i = 0 To currentForm.Controls.Count - 1
            If currentForm.Controls.Item(i).Name = "BindingNavigator1" Then

                Dim c As Control
                Dim ts As ToolStrip = currentForm.Controls.Item(i)
                For Each itm As ToolStripItem In ts.Items
                    If itm.Name = "tsStatus" Then
                        itm.Text = "Status: " & Process
                    End If

            End If
        Next i

    End Function

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
K-9Author Commented:
Able to resolve it with this code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.