Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How does Spring work with StatusStrips?

Spring is supported only in StatusStrip and only with StatusStripLabels. It utilizes the underlying Table layout with a columnstyle set to percentage to achieve the effect of the Spring panel filling the remaining space. Multiple ToolStripPanels set to Spring are sized equally, sharing the remaining space equally.

 class Form4 : Form
 {
  ToolStripStatusLabel middleLabel;

  public Form4()
  {
   // new StatusStrip
   StatusStrip ss = new StatusStrip();

   // add left label
   ss.Items.Add("Left");

   // handle middle label separately
   middleLabel = new ToolStripStatusLabel("Middle (Spring)");
   middleLabel.Click += new EventHandler(middleLabel_Click);
   ss.Items.Add(middleLabel);

   // add right label
   ss.Items.Add("Right");

   // Add the statusStrip to the controls collection
   this.Controls.Add(ss);
  }

  void middleLabel_Click(object sender, EventArgs e)
  {
   if (middleLabel.Spring)
   {
    middleLabel.Spring = false;
    middleLabel.Text = "Middle (Spring - False)";
   }
   else
   {
    middleLabel.Spring = true;
    middleLabel.Text = "Middle (Spring - True)";
   }
  }
 }


Page view counter