Home>

From the past, I've been revamping my email software.

Previously in Visual Studio 2005 etc., create two status labels
Create names as labelA and labelB, set Spring property to true for labelA
When the program is executed with labelB as it is, the text of labelB is not displayed
There was a problem.

What I want to do is to display the labelB character on the status bar.
Is it good?

Production environment: Visual Studio 2019 (Community)

Source code (Form1.Designer.cs)

namespace StatusBar
{
    partial class Form1
    {
        ///<summary>
        /// Required designer variable.
        ///</summary>
        private System.ComponentModel.IContainer components = null;
        ///<summary>
        /// Clean up all resources in use.
        ///</summary>
        ///<param name = "disposing">Specify true to dispose of the managed resource, false otherwise.</param>
        protected override void Dispose (bool disposing)
        {
            if (disposing&&(components! = null))
            {
                components.Dispose ();
            }
            base.Dispose (disposing);
        }
        #region Code generated by Windows Forms Designer
        ///<summary>
        /// Method required for designer support. The contents of this method
        /// Do not change in the code editor.
        ///</summary>
        private void InitializeComponent ()
        {
            this.statusStrip1 = new System.Windows.Forms.StatusStrip ();
            this.labelA = new System.Windows.Forms.ToolStripStatusLabel ();
            this.labelB = new System.Windows.Forms.ToolStripStatusLabel ();
            this.statusStrip1.SuspendLayout ();
            this.SuspendLayout ();
            //
            // statusStrip1
            //
            this.statusStrip1.ImageScalingSize = new System.Drawing.Size (20, 20);
            this.statusStrip1.Items.AddRange (new System.Windows.Forms.ToolStripItem [] {
            this.labelA,
            this.labelB});
            this.statusStrip1.Location = new System.Drawing.Point (0, 420);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size (800, 30);
            this.statusStrip1.TabIndex = 0;
            this.statusStrip1.Text = "statusStrip1";
            //
            // labelA
            //
            this.labelA.Name = "labelA";
            this.labelA.Size = new System.Drawing.Size (729, 24);
            this.labelA.Spring = true;
            this.labelA.Text = "Label A";
            this.labelA.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // labelB
            //
            this.labelB.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left;
            this.labelB.Name = "labelB";
            this.labelB.Size = new System.Drawing.Size (56, 24);
            this.labelB.Text = "Label B";
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF (8F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size (800, 450);
            this.Controls.Add (this.statusStrip1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.statusStrip1.ResumeLayout (false);
            this.statusStrip1.PerformLayout ();
            this.ResumeLayout (false);
            this.PerformLayout ();
        }
        #endregion
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel labelA;
        private System.Windows.Forms.ToolStripStatusLabel labelB;
    }
}
c#
  • Answer # 1

    When I moved the presented code, it did not appear.
    After resizing and saving the form in the designer,
    toForm1.Designer.cs
    this.statusStrip1.Padding = new System.Windows.Forms.Padding (1, 0, 10, 0);
    Has been added.
    When this line was deleted and executed again, label B was displayed.

    I'm not sure, but the past DPI setting is different from the current setting, so it may have been weird.
    Related links
    I want to display the items in StatusStrip with one on the left and one on the right.

Trends