C# WinForms: ToolStripStatusLabel and ToolStripSeparator

Posted on 2012-09-06
Last Modified: 2012-09-06
How do these two work together?

Question by:newbieweb
    LVL 48

    Accepted Solution

    You can add both to the statusStrip.

                var toolStripStatusLabel1 = new ToolStripStatusLabel();
                toolStripStatusLabel1.Text = (string)"Pos1";
                var toolStripSeparator = new ToolStripSeparator();
                var toolStripStatusLabel2 = new ToolStripStatusLabel();
                toolStripStatusLabel2.Text = (string)"Pos2";

    Open in new window


    Author Comment

    My WinForms C# program has definitions for ToolStripSeparator but I do not know where they were created ot how to access them. In the Designer.cs file

            private void InitializeComponent()
                this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
                this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
                this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();

            private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
            private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
            private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;

    A case insnesitive serach of my project for "Items.Add(tool" come up empty, so these are not being added.  

    A different deverloper created the ToolStripStatusLabel as well as the ToolStripSeparator.  Any idea how?  The ToolStripStatusLabel is obvious, but the existence of the 3 ToolStripSeparators confuses me.

    LVL 48

    Expert Comment

    You can add them in design ou in code, but you should have access to what you've created (this.ToolStripStatusLabel .Item(0)...

    Author Comment

    I will drop the designer concern.  The question is how what type of object do I drag onto the form?

    What type if the statusStrip1 in your example?

    Author Closing Comment

    Thanks, got it.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now